forked from jimp-dev/pngjs3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
96 lines (88 loc) · 2.38 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
92
93
94
95
96
import rollupBabel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import filesize from 'rollup-plugin-filesize';
import { terser } from 'rollup-plugin-terser';
import sourceMaps from 'rollup-plugin-sourcemaps';
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/png.js',
external: [],
};
export default [
{
...shared,
output: {
name: 'pngjs3',
file:
process.env.NODE_ENV === 'production' ?
'./dist/pngjs3.umd.min.js' :
'./dist/pngjs3.umd.js',
format: 'umd',
exports: 'named',
sourcemap: process.env.NODE_ENV !== 'production',
},
plugins: [
...sharedPlugins,
process.env.NODE_ENV === 'production' && filesize(),
process.env.NODE_ENV === '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',
exports: 'named',
sourcemap: true,
},
{
file: 'dist/pngjs3.js',
format: 'cjs',
exports: 'named',
sourcemap: true,
},
],
plugins: [
...sharedPlugins,
sourceMaps(),
process.env.NODE_ENV === 'production' && filesize(),
],
},
];