-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.dev.js
106 lines (95 loc) · 2.73 KB
/
rollup.dev.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
97
98
99
100
101
102
103
104
105
106
import babel from 'rollup-plugin-babel';
import cjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import replace from 'rollup-plugin-replace';
import postcss from 'rollup-plugin-postcss';
import postcssModules from 'postcss-modules';
const cssExportMap = {};
/**
* Exports a default object configuration for Rollup
* and mirrors the React/Rollup starter kit:
* https://github.com/yamafaktory/babel-react-rollup-starter
*/
export default {
/**
* React like the DOM is a tree so all
* we need to do is pull in the root.
*/
entry: 'src/Entrypoint.jsx',
/**
* Where to dump the JavaScript blob
*/
dest: 'dist/bundle.js',
/**
* iife stands for Immediately Invoked Function Expression
* which is what we want in the browser. The 'dest' bundle
* is what is run from the index.html in the final script tag.
*/
format: 'iife',
/**
* Helpful for debugging
*/
sourceMap: true,
/**
* Meat and potatoes for Rollup
*/
plugins: [
/**
* Babel is the transpiler
*/
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [ [ 'es2015', { modules: false } ], 'stage-0', 'react' ],
plugins: [ 'external-helpers' ]
}),
/**
* CSS modules
*/
postcss({
plugins: [
postcssModules({
getJSON (id, exportTokens) {
cssExportMap[id] = exportTokens;
}
})
],
getExport (id) {
return cssExportMap[id];
},
extensions: ['.css', '.scss']
}),
/**
* CJS stands for commonjs and the plugin
* converts CommonJS modules to ES6, so they
* can be included in a Rollup bundle.
*/
cjs({
/**
* Including individual modules would might
* the final bundle a tad smaller but the manual
* updating isn't worth the effort.
*/
include: 'node_modules/**'
}),
/**
* Helper for global objects (i.e. like process, tick etc.)
* that aren't present in the browser but exist
* in the node world.
*/
globals(),
/**
* Flag for development
*/
replace({
'process.env.NODE_ENV': JSON.stringify('development') }
),
/**
* Locate modules using the Node resolution algorithm,
* for using third party modules in node_modules
*/
resolve({
})
]
};