-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.mjs
94 lines (86 loc) · 2.25 KB
/
rollup.config.mjs
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
92
93
94
import rollupBabel from '@rollup/plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import terser from '@rollup/plugin-terser';
import nodeResolver from 'rollup-plugin-node-builtins';
import nodeGlobals from 'rollup-plugin-node-globals';
const commonJsResolver = commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**', // Default: undefined
// these values can also be regular expressions
// include: /node_modules/
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: true, // Default: false
// if false then skip sourceMap generation for CommonJS modules
sourceMap: true, // Default: true
});
const sharedPlugins = [
rollupBabel({
babelrc: false,
presets: [['@babel/env', { modules: false }], '@babel/flow'],
exclude: 'node_modules/**',
plugins: ['@babel/plugin-proposal-class-properties'],
}),
nodeGlobals(),
nodeResolver({ browser: true }),
commonJsResolver,
];
const shared = {
input: 'lib/index.js',
external: ['immer', 'browserify-zlib'],
};
const sharedModuleOutput = {
exports: 'named',
sourcemap: true,
globals: {
immer: 'immer',
'browserify-zlib': 'zlib',
},
};
const production = process.env.NODE_ENV !== 'production';
export default [
{
...shared,
output: {
name: 'pngjs3',
file: production ? './dist/pngjs3.umd.min.js' : './dist/pngjs3.umd.js',
format: 'umd',
exports: 'named',
sourcemap: production,
globals: {
immer: 'immer',
'browserify-zlib': 'zlib',
},
},
plugins: [
...sharedPlugins,
production &&
terser({
output: { comments: false },
compress: {
keep_infinity: true, // eslint-disable-line camelcase
pure_getters: true, // eslint-disable-line camelcase
},
warnings: true,
ecma: 6,
toplevel: false,
}),
],
},
{
...shared,
output: [
{
file: 'dist/pngjs3.es6.js',
format: 'es',
...sharedModuleOutput,
},
{
file: 'dist/pngjs3.js',
format: 'cjs',
...sharedModuleOutput,
},
],
plugins: [...sharedPlugins],
},
];