This repository was archived by the owner on Jun 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
70 lines (58 loc) · 1.58 KB
/
webpack.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
var webpack = require('webpack');
var build = Boolean(process.env.BUILD);
var dev = !build;
var config = {
entry: './main',
resolve: {
root: __dirname + '/src',
},
module: {
loaders: []
},
target: 'electron'
};
var loaders = {
hot: {
test: /\.js$/,
exclude: __dirname + '/node_modules',
loader: 'react-hot',
},
babel: {
test: /\.js$/,
exclude: __dirname + '/node_modules',
loader: 'babel',
query: {
presets: ['es2015', 'react']
},
},
stylesDev: {
test: /\.s?css$/,
exclude: __dirname + '/node_modules',
loaders: ['style', 'css', 'sass'],
},
stylesBuild: {
test: /\.s?css$/,
exclude: __dirname + '/node_modules',
loaders: ['style/url', 'file?name=[hash].css', 'extract', 'css', 'sass'],
}
};
plugins = {
nodeEnvProduction: new webpack.DefinePlugin({
'process.env': {'NODE_ENV': '"production"'}
}),
uglify: new webpack.optimize.UglifyJsPlugin({
compress: {warnings: true}
}),
dedupe: new webpack.optimize.DedupePlugin()
};
if (dev) {
config['output'] = {path: 'static', filename: 'bundle.js'};
config['module']['loaders'] = [loaders.hot, loaders.babel, loaders.stylesDev];
config['devtool'] = 'source-map';
}
if (build) {
config['output'] = {path: 'build', filename: '[hash].js'};
config['module']['loaders'] = [loaders.babel, loaders.stylesBuild];
config['plugins'] = [plugins.nodeEnvProduction, plugins.dedupe, plugins.uglify];
}
module.exports = config;