-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (32 loc) · 945 Bytes
/
server.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
30
31
32
33
34
35
36
37
38
39
40
// @flow
'use strict'
const path = require('path')
const Express = require('express')
const Morgan = require('morgan')
const Webpack = require('webpack')
const WebpackDevMW = require('webpack-dev-middleware')
const WebpackHotMW = require('webpack-hot-middleware')
const conf = require('./config')
const webpackConf = require('./webpack.config')
const app = Express()
const compiler = Webpack(webpackConf)
app.use(Morgan(conf.get('logging.format')))
app.use(Express.static('public'))
app.use(WebpackDevMW(compiler, {
publicPath: webpackConf.output.publicPath,
stats: {
colors: true,
hash: false,
timings: false,
chunks: false,
chunkModules: false,
modules: false
}
}))
app.use(WebpackHotMW(compiler))
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'index.html'))
})
app.listen(conf.get('server.port'), () => {
console.log(`Server listening on port ${conf.get('server.port')}`)
})