You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
const express = require('express');
|
|
const webpack = require('webpack');
|
|
const middleware = require('webpack-dev-middleware');
|
|
const proxy = require('koa-better-http-proxy');
|
|
const url = require('url');
|
|
const devConfig = require('../webpack.config');
|
|
|
|
const compiler = webpack(devConfig);
|
|
|
|
module.exports = {
|
|
entry(app, router, opts) {
|
|
app.use(proxy('http://localhost:5001', {
|
|
filter(ctx) {
|
|
return /\/build/.test(url.parse(ctx.url).path);
|
|
},
|
|
proxyReqPathResolver(ctx) {
|
|
return `client${url.parse(ctx.url).path}`;
|
|
},
|
|
}));
|
|
|
|
app.use(proxy('http://localhost:5001', {
|
|
filter(ctx) {
|
|
return /\/$/.test(url.parse(ctx.url).path);
|
|
},
|
|
proxyReqPathResolver(ctx) {
|
|
return 'client/build/index.html';
|
|
},
|
|
}));
|
|
|
|
const server = express();
|
|
server.use(middleware(compiler));
|
|
// server.use(require("webpack-hot-middleware")(compiler));
|
|
server.listen('5001', (err) => {
|
|
if (err) {
|
|
console.log(err);
|
|
}
|
|
});
|
|
},
|
|
};
|
|
|