-
Notifications
You must be signed in to change notification settings - Fork 0
/
hot.js
29 lines (28 loc) · 1.03 KB
/
hot.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
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const webpackHotServerMiddleware = require('webpack-hot-server-middleware');
const config = require('./webpack.config.js')({ production: false });
const clientConfig = require('./webpack.client.js')({ production: false });
const app = express();
const compiler = webpack(config);
const publicPath = clientConfig.output.publicPath;
const outputPath = clientConfig.output.path;
app.use('/dll', express.static(path.join(__dirname, 'dll')));
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath }));
app.use(
webpackHotMiddleware(compiler.compilers.find(comp => comp.name === 'client'))
);
app.use(
webpackHotServerMiddleware(compiler, {
serverRendererOptions: {
outputPath,
production: false
}
})
);
app.listen(5000, () => {
console.log('Server started: http://localhost:5000');
});