-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
72 lines (66 loc) · 1.54 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
71
72
/* eslint-disable import/no-commonjs */
const __DEV__ = process.env.NODE_ENV !== 'production';
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const plugins = [
new webpack.EnvironmentPlugin('NODE_ENV'),
new webpack.DefinePlugin({
__DEV__: JSON.stringify(__DEV__)
}),
new webpack.LoaderOptionsPlugin({
minimize: !__DEV__,
debug: __DEV__
}),
];
const entry = [
'./src/ui/Client',
];
const babelrc = JSON.parse(fs.readFileSync(path.join(__dirname, '.babelrc.web.json'), 'utf-8').toString());
module.exports = {
devtool: 'source-map',
entry: __DEV__ ? [ ...entry, 'webpack-hot-middleware/client' ] : [ ...entry ],
output: {
path: path.resolve(__dirname, 'static/dist/scripts'),
publicPath: '/s/dist/scripts/',
filename: 'bundle.min.js',
sourceMapFilename: 'bundle.min.js.map'
},
plugins: plugins.concat(__DEV__ ? [
new webpack.HotModuleReplacementPlugin(),
] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
]),
resolve: {
extensions: [ '', '.web.js', '.js', ],
},
module: {
preLoaders: [
{
test: /\.js$/,
loader: 'eslint?quiet=true',
exclude: /node_modules/
}
],
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: Object.assign({}, babelrc, {
presets: babelrc.presets.map(p => p.startsWith('es2015') ? 'es2015-native-modules' : p),
env: {
developement: {
presets: [ 'react-hmre' ],
},
}
})
},
{
test: /\.json$/,
loader: 'json'
}
]
}
};