-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathserver.dev.js
More file actions
36 lines (30 loc) · 773 Bytes
/
Copy pathserver.dev.js
File metadata and controls
36 lines (30 loc) · 773 Bytes
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
/* eslint no-console:0 */
import path from 'path';
import express from 'express';
import webpack from 'webpack';
import config from './webpack.config';
import opn from 'opn';
const app = express();
const compiler = webpack(config);
const port = 3000;
let opened = false;
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(compiler));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'src/index.html'));
});
app.listen(port, (err) => {
if (err) {
console.log(err);
return;
}
if (!opened) {
opn(`http://localhost:${port}`);
opened = true;
}
console.log('Dev Server');
console.log(`🌎 Listening on port ${port}`);
});