fix(generator): avoid error if nuxt/config.js does not exists in buildDir (#7332)

This commit is contained in:
Sébastien Chopin 2020-05-08 13:55:39 +02:00 committed by GitHub
parent 917adc0618
commit 29ebccaa65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ export default class Generator {
)
}
const config = this.getBuildConfig()
if (config.target !== TARGETS.static) {
if (!config || config.target !== TARGETS.static) {
throw new Error(
`In order to use \`nuxt export\`, you need to run \`nuxt build --target static\``
)
@ -128,7 +128,11 @@ export default class Generator {
}
getBuildConfig () {
try {
return require(path.join(this.options.buildDir, 'nuxt/config.json'))
} catch (err) {
return null
}
}
getAppRoutes () {