-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
32 lines (27 loc) · 853 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
// New Relic
require("newrelic")
// Modules
const express = require("express")
const { existsSync } = require("fs")
const { resolve } = require("path")
const { Nuxt } = require("nuxt")
const options = require("./nuxt.config")
// Force production mode (no webpack middleware called)
options.dev = false
// Start Nuxt.js
const nuxt = new Nuxt(options)
// Check if project is built for production
const distDir = resolve(
nuxt.options.rootDir,
nuxt.options.buildDir || ".nuxt",
"dist"
)
if (!existsSync(distDir)) {
console.error(
"> No build files found, please run `nuxt build` before launching `npm start`"
) // eslint-disable-line no-console
process.exit(1)
}
const port = process.env.PORT || process.env.npm_package_config_nuxt_port
const host = process.env.HOST || process.env.npm_package_config_nuxt_host
nuxt.listen(port, host)