forked from react-d3/react-d3-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
67 lines (58 loc) · 1.37 KB
/
webpack.prod.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
'use strict';
var path = require('path'),
webpack = require('webpack'),
nodeModulesPath = path.join(__dirname, 'node_modules');
var js_root = './lib/';
var js_dist = __dirname;
// 0 stands for development, 1 stands for production
// for development mode: NODE_ENV=0 webpack
// for production mode: NODE_ENV=1 webpack
var ENV = !!(+process.env.NODE_ENV || 0);
module.exports = [{
name: 'prod',
entry: {
"react-d3-core": js_root + 'index.js',
},
output: {
libraryTarget: "var",
library: "ReactD3Core",
path: js_dist,
filename: ENV ? '[name].min.js' : '[name].js'
},
module: {
loaders: [{
loader: 'babel-loader',
test: [/\.jsx$/, /\.js$/],
exclude: /node_modules/,
query: {
presets: ['react', 'es2015', 'stage-0']
}
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}],
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx']
},
externals: {
//don't bundle the 'react' npm package with our bundle.js
//but get it from a global 'React' variable
'react': 'React',
'react-dom': 'ReactDOM',
'd3': 'd3'
},
plugins: ENV ? [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
mangle: false
}),
new webpack.ProvidePlugin({
'd3': 'd3'
})
] : [
new webpack.ProvidePlugin({
'd3': 'd3'
})
]
}];