-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·41 lines (35 loc) · 987 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
41
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import DashboardPlugin from 'webpack-dashboard/plugin'
import config from './webpack.config.babel'
const app = new (require('express'))()
const port = 3000
const env = process.env.NODE_ENV
const DEV = env === 'development'
const compiler = webpack(config)
compiler.apply(new DashboardPlugin())
app.use(webpackDevMiddleware(
compiler,
{
noInfo: true,
publicPath: config.output.publicPath
}
))
app.use(webpackHotMiddleware(compiler))
app.get("*", function(req, res) {
res.sendFile(`${ __dirname }/index${ DEV ? '_dev' : '' }.html`)
})
app.listen(port, function(error) {
if (error) {
console.error(error)
} else {
console.info(
`==> 🌎 Online Cameras application listening on port ${
port
}. Open up http://localhost:${
port
}/ in your browser.`
)
}
})