-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
40 lines (37 loc) · 1019 Bytes
/
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
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import bundleAnalyzer from 'rollup-plugin-bundle-analyzer';
const args = process.argv.slice(2);
const getArgvParameter = (argv, key) => {
const value = argv.find((item) => item.includes(key))?.split('=')[1] || '';
return value.trim().replace(/"/g, '').replace(/'/g, '');
};
const plugins = [];
const analyze = getArgvParameter(args, '--analyze');
if (analyze) plugins.push(bundleAnalyzer({}));
export default [
{
input: 'src/index.ts',
output: {
exports: 'named',
file: 'dist/index.modern.js',
format: 'es',
sourcemap: false,
},
external: ['react', 'library-react-hooks'],
treeshake: 'recommended',
plugins: [
typescript({
tsconfig: './tsconfig.json',
include: ['src/**/*.ts'],
exclude: ['src/**/**/*.test.ts'],
}),
terser({
output: {
comments: false,
},
}),
...plugins,
],
},
];