-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (30 loc) · 1.12 KB
/
server.js
File metadata and controls
35 lines (30 loc) · 1.12 KB
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
var webpack = require('webpack'); // 打包工具
var WebpackDevServer = require('webpack-dev-server'); // 一个小型的Node.js Express服务器
var config = require('./webpack.config.dev'); // 正常编译配置
// 代理服务器
var proxy = [{
path: '/*/*', //必须得有一个文件地址,如果顶层文件夹名字不同,则用/*代替
//target: 'http://120.24.238.195:8080/WIFIProbeAnalysis_web-1.0-SNAPSHOT/',
host: 'http://localhost:8080/',
//host: 'http://120.24.238.195:8080/WIFIProbeAnalysis_web-1.0-SNAPSHOT/',
target: 'http://localhost:8080/',
secure: false
}];
/* 下面是创建一个服务对象,固定写法 */
/*server test*/
var server = new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath, // 文件相对引用路径,就用配置文件中配置的
progress: true,
stats: {
colors: true
},
proxy
});
// 将其他路由,全部返回index.html
server.app.get('*', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
// 监听8888端口
server.listen(8888, function() {
console.log('成功开启8888端口');
});