-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
27 lines (24 loc) · 845 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
import express from 'express'
import compression from 'compression'
import httpProxy from 'http-proxy'
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import webpackConfig from './webpack.config.dev.babel'
const { API_HOST, API_PORT, HTTP_PORT } = process.env
const app = express()
const compiler = webpack(webpackConfig)
const proxy = httpProxy.createProxyServer({
target: `http://${API_HOST}:${API_PORT}`,
})
app.use(compression())
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
stats: { colors: true },
}))
app.use(webpackHotMiddleware(compiler))
app.use(express.static('dist'))
app.use('/api', proxy.web)
app.listen(HTTP_PORT, () => {
console.log(` >>> http://localhost:${HTTP_PORT} <<<`)
})