forked from chenjun1127/react-music
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (44 loc) · 1.38 KB
/
app.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
// 引入模块
const express = require('express');
const webpackDevMiddleware = require("webpack-dev-middleware");
const WebpackHotMiddleware = require('webpack-hot-middleware');
const webpack = require("webpack");
const proxy = require('http-proxy-middleware');
const app = express();
const config = require('./webpack.config');
config.entry.app.unshift("webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000");
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
historyApiFallback: true,
hot: true,
inline: true,
noInfo: false,
stats: {
colors: true,
}
}));
app.use(WebpackHotMiddleware(compiler));
const kugou = proxy('/kugou', {
target: 'http://m.kugou.com/',
changeOrigin: true,
pathRewrite: {"^/kugou": ""}
});
const yy_kugou = proxy('/yy_kugou', {
target: 'http://www.kugou.com/yy/',
changeOrigin: true,
pathRewrite: {"^/yy_kugou": ""}
});
const mobilecdn = proxy('/mobilecdn', {
target: 'http://mobilecdn.kugou.com',
changeOrigin: true,
pathRewrite: {"^/mobilecdn": ""}
});
app.use('/kugou/*', kugou);
app.use('/yy_kugou/*', yy_kugou);
app.use('/mobilecdn/*', mobilecdn);
const server = app.listen(3000, () => {
const host = server.address().address;
const port = server.address().port;
console.log('Listening at http://%s:%s', host, port);
});