-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
91 lines (90 loc) · 2.48 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
83
84
85
86
87
88
89
90
91
import { terser } from 'rollup-plugin-terser';
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import visualizer from 'rollup-plugin-visualizer';
import gzipPlugin from 'rollup-plugin-gzip';
import brotli from 'rollup-plugin-brotli';
import analyzer from 'rollup-plugin-analyzer';
export default {
input: 'src/framework.js',
output: [
{
file: 'dist/bundle.cjs.js',
format: 'cjs',
sourcemap: process.env.NODE_ENV !== 'production',
},
{
file: 'dist/bundle.esm.js',
format: 'esm',
sourcemap: process.env.NODE_ENV !== 'production',
},
],
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
tryCatchDeoptimization: false,
},
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
plugins: ['@babel/plugin-transform-runtime'],
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: 3,
targets: '> 1%, not dead',
modules: false,
},
],
],
}),
terser({
compress: {
drop_console: true,
drop_debugger: true,
negate_iife: true,
booleans_as_integers: true,
hoist_vars: true,
passes: 5,
ecma: 2020,
inline: 3,
pure_funcs: ['console.log'],
dead_code: true,
unused: true,
collapse_vars: true,
reduce_vars: true,
sequences: true,
conditionals: true,
booleans: true,
toplevel: true,
unsafe: true,
unsafe_comps: true,
unsafe_math: true,
unsafe_undefined: true,
},
mangle: {
toplevel: true,
properties: true,
},
format: {
ascii_only: true,
},
keep_fnames: false,
keep_classnames: false,
}),
gzipPlugin(),
brotli(),
visualizer({ open: true, filename: 'stats.html', compress: true}),
analyzer({ summaryOnly: true,
exclude: ['node_modules/**', 'dist/**'], // Exclude node_modules and dist folders from size analysis
statsFilename: 'bundle-stats.json', // Output stats to a JSON file for further analysis and visualization with tools like webpack-bundle-analyzer or rollup-plugin-visualizer-bundle-size-analyzer
}), // Rollup plugin analyzer for detailed size analysis
],
external: ['rxjs'],
};