-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.dev.js
34 lines (29 loc) · 962 Bytes
/
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
/* webpack.dev.js */
var webpack = require("webpack");
var WebpackDevServer = require("webpack-dev-server");
var config = require("./webpack.config");
var utils = require("./utils");
var PORT = 80;
var HOST = utils.getIP();
var args = process.argv;
var hot = args.indexOf("--hot") > -1;
var deploy = args.indexOf("--deploy") > -1;
// 本地环境静态资源路径
var localPublicPath = "http://" + HOST + ":" + PORT + "/";
config.output.publicPath = localPublicPath;
config.entry.app.unshift("webpack-dev-server/client?" + localPublicPath);
new WebpackDevServer(webpack(config), {
hot: hot,
inline: true,
compress: true,
stats: {
chunks: false,
children: false,
colors: true
},
// Set this as true if you want to access dev server from arbitrary url.
// This is handy if you are using a html5 router.
historyApiFallback: true,
}).listen(PORT, HOST, function() {
console.log(localPublicPath);
});