-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
57 lines (54 loc) · 1.63 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
// plugins that we are going to use
import babel from 'rollup-plugin-babel';
import pkg from './package.json';
// list of plugins used during building process
const plugins = (targets) => [
// use Babel to transpile to ES5
babel({
// ignore node_modules/ in transpilation process
exclude: 'node_modules/**',
// ignore .babelrc (if defined) and use options defined here
babelrc: false,
// use recommended babel-preset-env without es modules enabled
// and with possibility to set custom targets e.g. { node: '8' }
presets: [['@babel/preset-env', { modules: false, targets }]],
// solve a problem with spread operator transpilation https://github.com/rollup/rollup/issues/281
plugins: ['@babel/plugin-proposal-object-rest-spread'],
// removes comments from output
comments: true,
}),
];
// packages that should be treated as external dependencies, not bundled
const external = []; // e.g. ['axios']
export default [
{
// source file / entrypoint
input: 'src/index.js',
// output configuration
output: {
// name visible for other scripts
name: 'middyReroute',
// output file location
file: pkg.module,
// format of generated JS file, also: esm, and others are available
format: 'esm',
// add sourcemaps
sourcemap: true,
},
external,
// build es modules for node 8
plugins: plugins({ node: '8' }),
},
{
input: 'src/index.js',
output: {
name: 'middyReroute',
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
external,
// build common JS for node 6
plugins: plugins({ node: '6' }),
},
];