forked from pwa-builder/PWABuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (22 loc) · 979 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
// Custom server from official example https://github.com/nuxt/nuxt.js/blob/dev/examples/custom-server/server.js
// We need this because we are on Azure, if is not your case or similar you can
// add to your package.json the script: "start": "cross-env NODE_ENV=production nuxt start"
// Add production as fallback if you haven not configured the environment
process.env.NODE_ENV = process.env.NODE_ENV;
process.env.HOST = process.env.HOST || '127.0.0.1'
process.env.PORT = process.env.PORT || 3000
const app = require('express')()
const { Nuxt, Builder } = require('nuxt')
// Import and set Nuxt.js options
let config = require('./nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')
const nuxt = new Nuxt(config)
// Start build process in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
builder.build()
}
// Give nuxt middleware to express
app.use(nuxt.render)
// Start express server
app.listen(process.env.PORT, process.env.HOST)