feat(Webpack): Update to latest

This commit is contained in:
Berkeley Martinez
2018-01-08 20:09:54 -08:00
parent c372bd3cc5
commit e384f6a90c
3 changed files with 1185 additions and 457 deletions

View File

@@ -19,30 +19,31 @@ module.exports = {
net: 'empty'
},
output: {
filename: __DEV__ ? 'bundle.js' : 'bundle-[hash].js',
filename: __DEV__ ? '[name].js' : '[name]-[hash].js',
chunkFilename: __DEV__ ?
'bundle-[name].js' :
'bundle-[name]-[chunkhash].js',
'[name].js' :
'[name]-[chunkhash].js',
path: path.join(__dirname, '/public/js'),
publicPath: '/js'
},
resolve: {
alias: {
'dist/rx.all.js': 'rx/dist/rx.all.js'
}
},
module: {
loaders: [
{
test: /\.jsx?$/,
include: [
path.join(__dirname, 'client/'),
path.join(__dirname, 'common/')
],
loaders: __DEV__ ? ['react-hot', 'babel'] : [ 'babel' ]
},
{
test: /\.json$/,
loaders: [
'json-loader'
]
}
]
rules: [{
test: /\.jsx?$/,
include: [
path.join(__dirname, 'client/'),
path.join(__dirname, 'common/'),
path.join(__dirname, 'server/')
],
use: [
__DEV__ && 'react-hot-loader',
'babel-loader'
].filter(Boolean)
}]
},
externals: {
codemirror: 'CodeMirror',
@@ -59,11 +60,7 @@ module.exports = {
new webpack.NormalModuleReplacementPlugin(
/debug\/node/,
'debug/src/browser'
),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(true),
// this will output a .html file in output.path
new Visualizer({ filename: 'webpack-bundle-stats.html' })
)
]
};
@@ -78,6 +75,8 @@ if (!__DEV__) {
} else {
module.exports.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
new webpack.NoErrorsPlugin(),
// this will output a .html file in output.path
new Visualizer({ filename: 'webpack-bundle-stats.html' })
);
}