This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
64 lines (59 loc) · 1.48 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
const path = require('path');
const webpack = require('webpack');
const env = process.env.NODE_ENV;
const port = +(process.env.PORT || 3000) + 1;
const config = {
entry: './src/client',
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js',
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env),
API_URL: JSON.stringify('/api'),
},
}),
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
include: path.join(__dirname, 'src'),
}],
},
resolve: {
extensions: ['', '.js'],
},
};
const development = Object.assign({}, config, {
devtool: 'inline-source-map',
entry: ['webpack-hot-middleware/client'].concat(config.entry),
output: Object.assign({}, config.output, {
publicPath: `http://localhost:${port}/`,
}),
plugins: config.plugins.concat(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
),
});
const production = Object.assign({}, config, {
devtool: 'hidden-source-map',
output: Object.assign({}, config.output, {
publicPath: '/',
}),
plugins: config.plugins.concat(
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: {
warnings: false,
drop_console: true,
screw_ie8: true,
},
})
),
});
module.exports = env === 'production' ? production : development;