-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
64 lines (62 loc) · 1.82 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
import babel from 'rollup-plugin-babel'
import url from 'rollup-plugin-url'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import replace from 'rollup-plugin-replace'
import sourcemaps from 'rollup-plugin-sourcemaps'
import filesize from 'rollup-plugin-filesize'
import uglify from 'rollup-plugin-uglify'
import postcss from 'rollup-plugin-postcss'
import postcssModules from 'postcss-modules'
import postcssImport from 'postcss-import'
import cssnext from 'postcss-cssnext'
const cssExportMap = {}
export default {
entry: 'client/src/app.js',
format: 'iife',
sourceMap: true,
plugins: [
url({
limit: 10 * 1024, // inline files < 10k, copy files > 10k
include: ['**/*.svg'] // defaults to .svg, .png, .jpg and .gif files
}),
postcss({
plugins: [
postcssImport(),
cssnext(),
postcssModules({
getJSON (id, exportTokens) {
cssExportMap[id] = exportTokens
}
})
],
getExport (id) {
return cssExportMap[id]
}
}),
babel({
exclude: 'node_modules/**'
}),
nodeResolve({
jsnext: true,
main: true
}),
commonjs({
include: 'node_modules/**',
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/react/react.js': ['PropTypes', 'Component'],
'node_modules/victory-chart/lib/index.js': ['VictoryArea', 'VictoryBar']
}
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
sourcemaps(),
filesize(),
process.env.NODE_ENV === 'production' && uglify()
],
dest: 'client/dist/app.bundle.js' // equivalent to --output
}