forked from oovg/word-up
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (27 loc) · 990 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
const http = require('http')
const express = require('express')
const app = express()
app.use(require('morgan')('short'));
/* eslint-disable */
(function initWebpack() {
const webpack = require('webpack')
const webpackConfig = require('./webpack/common.config.babel')
const compiler = webpack(webpackConfig)
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true, publicPath: webpackConfig.output.publicPath
}))
app.use(require('webpack-hot-middleware')(compiler, {
log: console.log, path: '/__webpack_hmr', heartbeat: 10 * 1000
}))
app.use(express.static(__dirname + '/'))
})()
app.get(/.*/, function root(req, res) {
res.sendFile(__dirname + '/src/index.html')
})
const server = http.createServer(app)
server.listen(process.env.PORT || 3000, function onListen() {
const address = server.address()
console.log('Listening on: %j', address)
console.log(' -> that probably means: http://localhost:%d', address.port)
})
/* eslint-disable */