mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
28 lines
686 B
JavaScript
28 lines
686 B
JavaScript
const Nuxt = require('../../')
|
|
const app = require('express')()
|
|
const host = process.env.HOST || '127.0.0.1'
|
|
const port = process.env.PORT || 3000
|
|
|
|
global.fetch = require('node-fetch')
|
|
|
|
// Import and Set Nuxt.js options
|
|
let config = require('./nuxt.config.js')
|
|
config.dev = !(process.env.NODE_ENV === 'production')
|
|
|
|
// Init Nuxt.js
|
|
const nuxt = new Nuxt(config)
|
|
app.use(nuxt.render)
|
|
|
|
// Build only in dev mode
|
|
if (config.dev) {
|
|
nuxt.build()
|
|
.catch((error) => {
|
|
console.error(error) // eslint-disable-line no-console
|
|
process.exit(1)
|
|
})
|
|
}
|
|
|
|
// Listen the server
|
|
app.listen(port, host)
|
|
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
|