-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
23 lines (19 loc) · 795 Bytes
/
Copy pathserver.js
File metadata and controls
23 lines (19 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const path = require('path'),
express = require('express'),
webpack = require('webpack'),
webpackConfig = require('./webpack.config.js'),
app = express(),
port = process.env.PORT || 3100;
app.listen(port, () => { console.log(`App is listening on port ${port}`) });
// app.get('/*', (req, res) => {
// res.sendFile(path.resolve(__dirname, 'public', 'index.html'));
// });
let compiler = webpack(webpackConfig);
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true, publicPath: webpackConfig.output.publicPath, stats: { colors: true }
}));
app.use(require('webpack-hot-middleware')(compiler));
app.use(express.static(path.resolve(__dirname, 'public')));
app.get('/*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'public', 'index.html'));
});