2015-11-11 21:29:33 +00:00
|
|
|
var webpack = require('webpack');
|
2015-06-29 16:50:25 +00:00
|
|
|
var path = require('path');
|
2016-03-21 04:43:36 +00:00
|
|
|
var ManifestPlugin = require('webpack-manifest-plugin');
|
|
|
|
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
|
2015-11-23 04:26:44 +00:00
|
|
|
|
|
|
|
var __DEV__ = process.env.NODE_ENV !== 'production';
|
2015-06-29 16:50:25 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2016-03-21 04:43:36 +00:00
|
|
|
entry: {
|
|
|
|
bundle: './client'
|
|
|
|
},
|
|
|
|
devtool: __DEV__ ? 'inline-source-map' : null,
|
2015-06-29 16:50:25 +00:00
|
|
|
output: {
|
2016-03-21 04:43:36 +00:00
|
|
|
filename: __DEV__ ? 'bundle.js' : 'bundle-[hash].js',
|
|
|
|
chunkFilename: __DEV__ ?
|
|
|
|
'bundle-[name].js' :
|
|
|
|
'bundle-[name]-[chunkhash].js',
|
2015-06-29 16:50:25 +00:00
|
|
|
path: path.join(__dirname, '/public/js'),
|
2016-03-15 00:22:56 +00:00
|
|
|
publicPath: __DEV__ ? 'http://localhost:2999/js' : '/js'
|
2015-06-29 16:50:25 +00:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
include: [
|
|
|
|
path.join(__dirname, 'client/'),
|
|
|
|
path.join(__dirname, 'common/')
|
|
|
|
],
|
|
|
|
loaders: [
|
|
|
|
'babel-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
loaders: [
|
|
|
|
'json-loader'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2016-03-06 05:06:04 +00:00
|
|
|
externals: {
|
2016-05-06 20:20:18 +00:00
|
|
|
codemirror: 'CodeMirror'
|
2016-03-06 05:06:04 +00:00
|
|
|
},
|
2015-11-23 04:26:44 +00:00
|
|
|
plugins: [
|
2015-11-11 21:29:33 +00:00
|
|
|
new webpack.optimize.DedupePlugin(),
|
|
|
|
new webpack.optimize.OccurenceOrderPlugin(true),
|
2015-11-23 04:26:44 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
2016-05-06 20:20:18 +00:00
|
|
|
NODE_ENV: JSON.stringify(__DEV__ ? 'development' : 'production')
|
2015-11-23 04:26:44 +00:00
|
|
|
},
|
2016-05-06 20:20:18 +00:00
|
|
|
__DEVTOOLS__: !__DEV__
|
2016-03-21 04:43:36 +00:00
|
|
|
})
|
2015-11-23 04:26:44 +00:00
|
|
|
]
|
2015-06-29 16:50:25 +00:00
|
|
|
};
|
2016-03-21 04:43:36 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
);
|
|
|
|
}
|