1 | const Express = require('express')
|
2 | const WorkboxPlugin = require('workbox-webpack-plugin')
|
3 |
|
4 | const appConfig = require('../utils/get-app-config')
|
5 |
|
6 | const webpackDevMiddleware = require('./middlewares/webpack.dev')
|
7 | const proxyMiddleware = require('./middlewares/proxy')
|
8 |
|
9 | module.exports = function createApp(options, onStart = () => {}) {
|
10 | const app = Express()
|
11 |
|
12 | app.use(Express.static('public'))
|
13 |
|
14 | if (process.env.NODE_ENV === 'development') {
|
15 | webpackDevMiddleware(app)
|
16 | }
|
17 |
|
18 |
|
19 | app.use(proxyMiddleware)
|
20 |
|
21 | app.listen(appConfig.appPort, function () {
|
22 | console.log(`server is running in http://localhost:${appConfig.appPort}`)
|
23 | })
|
24 |
|
25 |
|
26 | onStart()
|
27 |
|
28 | return app
|
29 | } |
\ | No newline at end of file |