-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.development.js
More file actions
33 lines (26 loc) · 907 Bytes
/
server.development.js
File metadata and controls
33 lines (26 loc) · 907 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
/* eslint-disable import/no-extraneous-dependencies */
const webpack = require('webpack')
const path = require('path')
const webpackMiddleware = require('webpack-dev-middleware')
const webpackHotMiddleware = require('webpack-hot-middleware')
const app = require('./server.base')
const config = require('./webpack.config.development')
const { PORT } = process.env
const compiler = webpack(config)
app.use(webpackMiddleware(compiler, {
publicPath: config.output.publicPath,
stats: {
colors: true
}
}))
app.use(webpackHotMiddleware(compiler))
app.get('*', (req, res, next) => {
const filename = path.join(compiler.outputPath, 'index.html')
compiler.outputFileSystem.readFile(filename, (err, result) => {
if (err) return next(err)
res.set('content-type', 'text/html')
res.send(result)
res.end()
})
})
app.listen(PORT, () => console.log(`App (dev) listening on http://localhost:${PORT}`))