-
Notifications
You must be signed in to change notification settings - Fork 14
/
rollup.config.js
80 lines (75 loc) · 1.75 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
'use strict';
let fs = require('fs'),
json = require('rollup-plugin-json'),
postcss = require('postcss'),
buble = require('rollup-plugin-buble'),
nodeResolve = require('rollup-plugin-node-resolve'),
commonjs = require('rollup-plugin-commonjs'),
scss = require('rollup-plugin-scss'),
//post CSS plugins:
comments = require('postcss-discard-comments'),
dupes = require('postcss-discard-duplicates'),
cssnext = require('postcss-cssnext'),
replace = require('rollup-plugin-replace');
function getPlugins({
external
}, withScss = true) {
const scssPlugins = [scss({
output(styles, styleNodes) {
postcss([cssnext, comments, dupes])
.process(styles)
.then(result => {
fs.writeFile('./dist/index.css', result.css);
});
}
})];
const defaultPlugins = [
json(),
buble({
objectAssign: '_extend',
exclude: ['./node_modules/**/*']
}),
nodeResolve({
browser: true,
jsnext: true,
main: true
}),
commonjs(),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
})
];
return withScss
? scssPlugins.concat(defaultPlugins)
: defaultPlugins;
}
function getConfig({
external = [],
globals = {},
input = 'client/index.js'
}, withScss = true) {
return {
input,
external,
globals,
plugins: getPlugins({external}, withScss),
};
}
module.exports = getConfig({
external: [
'underscore',
'react',
'react-dom',
'react-router-dom',
'doctrine-standalone',
'babel-standalone'
],
globals: {
'underscore': '_',
'react': 'React',
'react-dom': 'ReactDOM',
'react-router-dom':'ReactRouterDOM',
'doctrine-standalone': 'doctrine',
'babel-standalone': 'Babel'
}
});