Enabled HMR

This commit is contained in:
Andrey Okonetchnikov
2016-09-13 17:08:26 +02:00
parent 3deec4060f
commit 3f4bc929e9
4 changed files with 67 additions and 24 deletions

View File

@ -3,6 +3,9 @@ var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var path = require('path');
const HOST = 'localhost';
const PORT = '8080';
module.exports = {
module: {
loaders: [
@ -22,7 +25,13 @@ module.exports = {
query: {
cacheDirectory: true,
presets: ['react', 'es2015'],
plugins: ['transform-class-properties', 'transform-object-assign', 'transform-object-rest-spread', 'lodash']
plugins: [
'transform-class-properties',
'transform-object-assign',
'transform-object-rest-spread',
'lodash',
'react-hot-loader/babel'
]
}
}
]
@ -34,6 +43,9 @@ module.exports = {
],
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('cms.css', { allChunks: true }),
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
@ -42,16 +54,23 @@ module.exports = {
context: path.join(__dirname, 'src'),
entry: {
cms: './index',
cms: [
'webpack/hot/dev-server',
`webpack-dev-server/client?http://${HOST}:${PORT}/`,
'react-hot-loader/patch',
'./index'
],
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
filename: '[name].js',
publicPath: `http://${HOST}:${PORT}/`,
},
externals: [/^vendor\/.+\.js$/],
externals: [/^vendor\/.+\.js$/],
devServer: {
hot: true,
contentBase: 'example/',
historyApiFallback: true,
devTool: 'source-map'
devTool: 'cheap-module-source-map'
},
};