-
Notifications
You must be signed in to change notification settings - Fork 187
/
rollup.config.js
82 lines (69 loc) · 1.84 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import path from 'path';
import {babel} from '@rollup/plugin-babel';
import cssPlugin from '@jetbrains/rollup-css-plugin';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
import clear from 'rollup-plugin-clear';
import glob from 'glob';
const files = glob.sync(
[
'components/**/*.{js,jsx}',
// Style-only components
'components/form/form.css',
'components/input/input-legacy.css',
'components/input-size/input-size.css',
],
{
ignore: [
'**/__mocks__/**',
'components/error-page/*', // TODO Error page does not work because of importing GIF file
'components/error-page-ng/*',
'components/**/*.test.js',
'components/**/*.stories.js',
],
},
);
const TARGET_DIR = 'dist';
const extensions = ['.js', '.jsx'];
export default {
external: id => {
const isInternal = id.startsWith('.') || id.startsWith('/');
return !isInternal;
},
input: files,
output: {
dir: TARGET_DIR,
format: 'esm',
// exposed components
entryFileNames: chunkInfo => {
const dirName = path.basename(path.dirname(chunkInfo.facadeModuleId));
return `${dirName}/[name].js`;
},
chunkFileNames: '_helpers/[name].js',
assetFileNames: '[name][extname]', // effective for css styles
},
plugins: [
clear({
targets: [TARGET_DIR],
}),
json(),
resolve({extensions}),
babel({
babelHelpers: 'bundled',
browserslistEnv: 'dist',
extensions,
}),
cssPlugin({
include: '**/*.css',
exclude: 'node_modules/**',
extract: 'style.css',
// log: console.log, // Uncomment to log CSS processing
minimize: true,
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true,
}),
],
};