-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatewebpackconfig.js
More file actions
62 lines (56 loc) · 1.35 KB
/
createwebpackconfig.js
File metadata and controls
62 lines (56 loc) · 1.35 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
var path = require("path");
var webpack = require("webpack");
var isProd = process.env.NODE_ENV === 'production';
module.exports = function(opts) {
var entry, plugins;
//PROD mode
if (opts.prod) {
entry = [
path.resolve(__dirname, 'src/index.js')
];
plugins = [
new webpack.optimize.UglifyJsPlugin({ //Minify JS for production use
compress: {
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify("production")
}
})
];
}
//DEV mode
else {
entry = [
"webpack-dev-server/client?http://localhost:8080", //Enable hot reloading for DEV
"webpack/hot/only-dev-server",
path.resolve(__dirname, 'src/index.js')
];
plugins = [
new webpack.HotModuleReplacementPlugin(),
];
}
return {
entry: entry, //Compiled above - the JS file we start from
output: {
path: path.resolve(__dirname, 'build'),
publicPath: '/build/',
filename: "bundle.js" //Target for final compilation
},
//Also resolve JSX files
resolve: {
extensions: ['', '.js', '.jsx']
},
plugins: plugins, //Compiled above
module: {
loaders: [{
//Activate babel loader
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel']
}]
}
}
};