-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.dev.service.js
55 lines (51 loc) · 1.61 KB
/
webpack.dev.service.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
var WebpackDevServer = require("webpack-dev-server");
var webpack = require("webpack");
var webpackConfig = require('./webpack.config.js');
var compiler = webpack(webpackConfig);
var bird = require('birdv3');
var server = new WebpackDevServer(compiler, {
watchContentBase: true,
disableHostCheck: true,
// 允许绑定本地域名
allowedHosts: [
'xxx.xxx.com'
],
// before: function (app) {
// app.use(bird('./birdfileConfig.js'))
// },
hot: true,
historyApiFallback: true,
// It suppress error shown in console, so it has to be set to false.
quiet: false,
// It suppress everything except error, so it has to be set to false as well
// to see success build.
noInfo: false,
stats: {
// Config for minimal console.log mess.
assets: false,
colors: true,
version: false,
hash: false,
timings: false,
chunks: false,
chunkModules: false
},
proxy: {
"/api": {
target: "https://xxx.xxxx.com",
// 因为使用的是https,会有安全校验,所以设置secure为false
secure: false,
// port: 80,
// ingorePath 默认即为 false, 注释掉也可以
// ingorePath: false,
// changeOrigin是关键,如果不加这个就无法跳转请求
changeOrigin: true,
}
},
// contentBase不要直接指向pages,因为会导致css、js支援加载不到
contentBase: __dirname + '/src/',
}).listen(80, '0.0.0.0', function (err) {
if (err) {
console.log(err);
}
});