-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
46 lines (42 loc) · 1.1 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const APP_DIR = path.resolve(__dirname, 'src/client/app');
const BUILD_DIR = path.resolve(__dirname, 'src/client/public');
const MAIN_DIR = path.resolve(__dirname, 'src/client');
const PROD = process.env.NODE_ENV === 'production';
const commonPlugins = [
new HtmlWebpackPlugin({
filename: "index.html", // Writes to `config.output.path`.
inject: 'body',
template: MAIN_DIR + '/index.html',
})
];
const config = {
entry: APP_DIR + '/index.jsx',
output: {
path: BUILD_DIR,
filename: PROD ? 'bundle.min.js' : 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx?/,
include: APP_DIR,
loader: 'babel'
}
]
},
plugins:
PROD ? [
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
].concat(commonPlugins) : commonPlugins
};
module.exports = config;