mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
24 lines
543 B
JavaScript
24 lines
543 B
JavaScript
const resolve = require('path').resolve
|
|
const { Nuxt, Builder } = require('nuxt')
|
|
|
|
// Setup nuxt.js
|
|
let config = {}
|
|
try {
|
|
config = require('../../nuxt.config.js')
|
|
} catch (e) {}
|
|
config.rootDir = resolve(__dirname, '..', '..')
|
|
config.dev = process.env.NODE_ENV !== 'production'
|
|
|
|
const nuxt = new Nuxt(config)
|
|
if (config.dev) {
|
|
const builder = new Builder(nuxt)
|
|
builder.build()
|
|
} else {
|
|
process.nextTick(() => process.emit('nuxt:build:done'))
|
|
}
|
|
|
|
// Add nuxt.js middleware
|
|
module.exports = function (req, res) {
|
|
nuxt.render(req, res)
|
|
}
|