-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.dev.client.js
59 lines (46 loc) · 1.67 KB
/
webpack.dev.client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict'; // eslint-disable-line strict
// Import modules
const _ = require('lodash');
const path = require('path');
const webpack = require('webpack');
// Import production webpack configuration
const webpackProdConfig = require('./webpack.client');
// Import config
const config = require('./config');
// Make sure we don't clobber our other configuration.
const webpackConfig = _.cloneDeep(webpackProdConfig);
webpackConfig.debug = true;
webpackConfig.devtool = 'eval-source-map';
webpackConfig.babel = config.build.babel.client.dev;
webpackConfig.plugins = [
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify('development') },
__CLIENT__: true,
__SERVER__: false,
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
];
webpackConfig.devServer = {
publicPath: `http://localhost:${config.ports.webpack}/${config.files.client.out}/`,
contentBase: path.join(__dirname, config.files.staticAssets),
hot: true,
inline: true,
silent: true,
noInfo: true,
headers: { 'Access-Control-Allow-Origin': '*' },
stats: { colors: true },
};
// Update output information
webpackConfig.output.publicPath =
`http://localhost:${config.ports.webpack}/${config.files.client.out}/`;
webpackConfig.output.hotUpdateMainFilename = 'update/[hash]/update.json';
webpackConfig.output.hotUpdateChunkFilename = 'update/[hash]/[id].update.js';
// Add entry points
webpackConfig.entry.unshift(
`webpack-dev-server/client?http://localhost:${config.ports.webpack}`,
'webpack/hot/only-dev-server'
);
// Modify JS loader so that react-hot works
webpackConfig.module.loaders[0].loaders.unshift('react-hot');
module.exports = webpackConfig;