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');
|
2018-01-01 13:01:18 +00:00
|
|
|
const Visualizer = require('webpack-visualizer-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,
|
2016-08-19 01:23:44 +00:00
|
|
|
node: {
|
|
|
|
// Mock Node.js modules that Babel require()s but that we don't
|
|
|
|
// particularly care about.
|
|
|
|
fs: 'empty',
|
|
|
|
module: 'empty',
|
|
|
|
net: 'empty'
|
|
|
|
},
|
2015-06-29 16:50:25 +00:00
|
|
|
output: {
|
2018-01-09 04:09:54 +00:00
|
|
|
filename: __DEV__ ? '[name].js' : '[name]-[hash].js',
|
2016-03-21 04:43:36 +00:00
|
|
|
chunkFilename: __DEV__ ?
|
2018-01-09 04:09:54 +00:00
|
|
|
'[name].js' :
|
|
|
|
'[name]-[chunkhash].js',
|
2015-06-29 16:50:25 +00:00
|
|
|
path: path.join(__dirname, '/public/js'),
|
2016-09-27 17:57:56 +00:00
|
|
|
publicPath: '/js'
|
2015-06-29 16:50:25 +00:00
|
|
|
},
|
2018-01-09 04:09:54 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'dist/rx.all.js': 'rx/dist/rx.all.js'
|
|
|
|
}
|
|
|
|
},
|
2015-06-29 16:50:25 +00:00
|
|
|
module: {
|
2018-01-09 04:09:54 +00:00
|
|
|
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)
|
|
|
|
}]
|
2015-06-29 16:50:25 +00:00
|
|
|
},
|
2016-03-06 05:06:04 +00:00
|
|
|
externals: {
|
2016-05-20 19:42:26 +00:00
|
|
|
codemirror: 'CodeMirror',
|
|
|
|
'loop-protect': 'loopProtect'
|
2016-03-06 05:06:04 +00:00
|
|
|
},
|
2015-11-23 04:26:44 +00:00
|
|
|
plugins: [
|
|
|
|
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-08-19 01:23:44 +00:00
|
|
|
}),
|
2017-01-08 21:44:30 +00:00
|
|
|
// Use browser version of visionmedia-debug
|
|
|
|
new webpack.NormalModuleReplacementPlugin(
|
|
|
|
/debug\/node/,
|
|
|
|
'debug/src/browser'
|
2018-01-09 04:09:54 +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(),
|
2018-01-09 04:09:54 +00:00
|
|
|
new webpack.NoErrorsPlugin(),
|
|
|
|
// this will output a .html file in output.path
|
|
|
|
new Visualizer({ filename: 'webpack-bundle-stats.html' })
|
2016-03-21 04:43:36 +00:00
|
|
|
);
|
|
|
|
}
|