fix(cli): enable server for build when spa pages should be generated (#6525)

This commit is contained in:
Dmitry Molotkov 2019-10-08 11:33:42 +03:00 committed by Pooya Parsa
parent 2b1366b965
commit 136777de1d
2 changed files with 6 additions and 7 deletions

View File

@ -99,7 +99,6 @@ It's as simple as that!
Or you can start by using one of our starter templates:
- [starter](https://github.com/nuxt-community/starter-template): Basic Nuxt.js project template
- [express](https://github.com/nuxt-community/express-template): Nuxt.js + Express
- [koa](https://github.com/nuxt-community/koa-template): Nuxt.js + Koa
- [adonuxt](https://github.com/nuxt-community/adonuxt-template): Nuxt.js + AdonisJS

View File

@ -62,6 +62,7 @@ export default {
},
async run (cmd) {
const config = await cmd.getNuxtConfig({ dev: false, server: false, _build: true })
config.server = config.mode === 'spa' && cmd.argv.generate !== false
const nuxt = await cmd.getNuxt(config)
if (cmd.argv.lock) {
@ -72,15 +73,14 @@ export default {
}))
}
if (nuxt.options.mode !== 'spa' || cmd.argv.generate === false) {
if (nuxt.options.mode === 'spa' && cmd.argv.generate !== false) {
// Build + Generate for static deployment
const generator = await cmd.getGenerator(nuxt)
await generator.generate({ build: true })
} else {
// Build only
const builder = await cmd.getBuilder(nuxt)
await builder.build()
return
}
// Build + Generate for static deployment
const generator = await cmd.getGenerator(nuxt)
await generator.generate({ build: true })
}
}