-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.babel.js
66 lines (59 loc) · 1.54 KB
/
webpack.config.babel.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
var path = require('path');
var webpack = require('webpack');
var config = require('./config').default;
var bundlePlugins = [];
var bundleEntry;
var bundlePublicPath;
var bundleModules = {
loaders: [{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/,
}, {
test: /\.(png|jpg|ttf|eot|woff|woff2)$/,
loader: 'url-loader?limit=1000',
}],
preLoaders: [{
test: /\.(js|jsx)$/,
loader: 'eslint-loader',
exclude: /node_modules/,
}]
};
if (config.PROD_ENV) {
var uglyfier = new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
minimize: true,
});
bundleEntry = './src/client/app.jsx';
bundlePublicPath = '/assets/js';
bundlePlugins.push(uglyfier);
} else {
bundleEntry = [
'webpack-dev-server/client?http://localhost:' + config.DEV_SERVER_PORT,
'webpack/hot/only-dev-server',
'./src/client/app.jsx',
];
bundlePublicPath = 'http://localhost:' + config.DEV_SERVER_PORT + '/assets/js';
bundlePlugins.push(new webpack.HotModuleReplacementPlugin());
bundleModules.loaders[0] = {
test: /\.(js|jsx)$/,
loaders: ['react-hot', 'babel-loader'],
exclude: /node_modules/,
};
}
var bundle = {
name: 'bundle',
entry: bundleEntry,
output: {
path: path.resolve('public/js/'),
filename: config.PROD_ENV ? 'app.min.js' : 'app.js',
publicPath: bundlePublicPath,
},
devtool: config.PROD_ENV ? '' : 'source-map',
module: bundleModules,
plugins: bundlePlugins,
resolve: {
extensions: ['', '.js', '.jsx'],
},
};
module.exports = bundle;