-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.server.js
38 lines (28 loc) · 989 Bytes
/
webpack.server.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
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require("./webpack.config.js");
config.output.publicPath = 'http://localhost:8082/assets/';
config.entry.index.unshift("webpack/hot/only-dev-server");
config.entry.index.unshift("webpack-dev-server/client?http://localhost:8082"); // 将执替换js内联进去
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.devtool = 'eval';
config.module.loaders[0].query.presets.push("react-hmre");
config.module.loaders[0].query.plugins.push([
'react-transform', {
transforms: [{
transform : 'react-transform-hmr',
imports : ['react'],
locals : ['module']
}]
}
]);
var compiler = webpack(config);
var server = new WebpackDevServer(compiler, {
publicPath: '/assets/',
hot: true,
//historyApiFallback: true,
stats: {
colors: true // 用颜色标识
},
});
server.listen(8082);