-
Notifications
You must be signed in to change notification settings - Fork 44
/
webpack.dev.js
72 lines (67 loc) · 1.75 KB
/
webpack.dev.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const path = require('path')
const webpack = require('webpack')
const WebpackDevServer = require('webpack-dev-server')
const config = require('./webpack.base.js')
// Merge with base configuration
//-------------------------------
Object.assign(config, {
cache: true,
devtool: 'source-map', // eval eval-cheap-module-source-map source-map
entry: {
bundle: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:2002',
'webpack/hot/only-dev-server',
path.join(__dirname, 'src/config/client.js')
]
},
output: {
publicPath: 'http://localhost:2002/build/',
libraryTarget: 'var',
pathinfo: true
}
})
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.WatchIgnorePlugin([
path.join(__dirname, 'core'),
path.join(__dirname, 'build')
]),
new webpack.DefinePlugin({
'process.env.DEV': true,
'process.env.BROWSER': true,
'process.env.NODE_ENV': JSON.stringify('development')
})
)
// Run DEV server for hot-reloading
//---------------------------------
const compiler = webpack(config)
const port = 2002
new WebpackDevServer(compiler, {
publicPath: config.output.publicPath,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Expose-Headers': 'SourceMap,X-SourceMap'
},
hot: true,
historyApiFallback: true,
watchOptions: {
aggregateTimeout: 300,
poll: false
},
stats: {
colors: true,
hash: false,
timings: false,
version: false,
chunks: false,
modules: false,
children: false,
chunkModules: false
}
}).listen(port, '0.0.0.0', function(err) {
if (err) return console.error(err)
console.info('Running on port ' + port)
})