const express = require('express'); const webpack = require('webpack'); const webpackDevMiddleware = require('webpack-dev-middleware'); const webpackHotMiddleware = require('webpack-hot-middleware'); const WebpackConfig = require('./webpack.config'); const { createProxyMiddleware } = require('http-proxy-middleware'); const app = express(); const compiler = webpack(WebpackConfig); app.use( webpackDevMiddleware(compiler, { publicPath: '/__build__/', stats: { colors: true, chunks: false, }, }), ); const admin = express(); admin.get('/', function (req, res) { console.dir(admin.mountpath); // [ '/adm*n', '/manager' ] res.send('Admin Homepage'); }); app.use(['/admin', '/manager'], admin); app.use(webpackHotMiddleware(compiler)); app.use(express.static(__dirname)); // app.use('/', createProxyMiddleware('/', { target: 'http://127.0.0.1:8880', changeOrigin: true })); app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.167:8088/', changeOrigin: true })); // app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.178:8082', changeOrigin: true })); // app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.167:8088/', changeOrigin: true })); const port = process.env.PORT || 8888; module.exports = app.listen(port, () => { console.log(`Server listening on http://localhost:${port}, Ctrl+C to stop`); });