-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdevServer.js
More file actions
33 lines (25 loc) · 754 Bytes
/
Copy pathdevServer.js
File metadata and controls
33 lines (25 loc) · 754 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
import path from 'path'
import webpack from 'webpack'
import express from 'express'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import webpackConfig from './webpack.config'
const app = express()
const host = 'localhost'
const port = 3000
const compiler = webpack(webpackConfig)
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: webpackConfig.output.publicPath,
}))
app.use(webpackHotMiddleware(compiler))
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'example/index.html'))
})
app.listen(port, host, function (err) {
if (err) {
console.log(err)
return
}
console.log(`Server is now running at ${host}:${port}.`)
})