-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.js
More file actions
67 lines (65 loc) · 1.71 KB
/
rollup.config.js
File metadata and controls
67 lines (65 loc) · 1.71 KB
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
import resolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
// Convert CJS modules to ES6, so they can be included in a bundle
import commonjs from 'rollup-plugin-commonjs'
import postcss from 'rollup-plugin-postcss'
import postcssModules from 'postcss-modules'
import uglify from 'rollup-plugin-uglify'
import url from 'rollup-plugin-url'
const cssExportMap = {}
const isProd = process.env.NODE_ENV === 'production'
export default {
input: 'src/app.js',
output: {
file: 'dist/bundle.js',
format: 'cjs',
sourcemap: true
},
external: [
'react',
'react-proptypes',
'url',
'events',
'classnames',
'query-string'
],
plugins: [
resolve({
preferBuiltins: true
}),
url({
include: ['images/*'], // defaults to .svg, .png, .jpg and .gif files
emitFiles: true // defaults to true
}),
postcss({
plugins: [
postcssModules({
getJSON (id, exportTokens) {
cssExportMap[id] = exportTokens
}
})
],
extensions: ['.css'],
getExportNamed: false,
getExport (id) {
return cssExportMap[id]
},
extract: 'dist/bundle.css'
}),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers']
}),
commonjs({
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-dom/index.js': ['createPortal', 'findDOMNode'],
'node_modules/validate.js/validate.js': ['validate'],
'node_modules/react-is/index.js': ['isValidElementType']
}
}),
isProd && uglify(),
]
}