Add webpack code splitting module

Add cold-module replacement
Add webpack module hashing
This commit is contained in:
Berkeley Martinez
2016-03-20 21:43:36 -07:00
parent c77fcedcbb
commit 844afb6e2f
8 changed files with 189 additions and 203 deletions

View File

@@ -1,13 +1,20 @@
var webpack = require('webpack');
var path = require('path');
var ManifestPlugin = require('webpack-manifest-plugin');
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
var __DEV__ = process.env.NODE_ENV !== 'production';
module.exports = {
entry: './client',
devtool: 'inline-source-map',
entry: {
bundle: './client'
},
devtool: __DEV__ ? 'inline-source-map' : null,
output: {
filename: 'bundle.js',
filename: __DEV__ ? 'bundle.js' : 'bundle-[hash].js',
chunkFilename: __DEV__ ?
'bundle-[name].js' :
'bundle-[name]-[chunkhash].js',
path: path.join(__dirname, '/public/js'),
publicPath: __DEV__ ? 'http://localhost:2999/js' : '/js'
},
@@ -42,8 +49,21 @@ module.exports = {
'NODE_ENV': JSON.stringify(__DEV__ ? 'development' : 'production')
},
'__DEVTOOLS__': !__DEV__
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
})
]
};
if (!__DEV__) {
module.exports.plugins.push(
new ManifestPlugin({ fileName: 'react-manifest.json' }),
new ChunkManifestPlugin({
filename: 'chunk-manifest.json',
manifestVariable: 'webpackManifest'
})
);
} else {
module.exports.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
);
}