Nuxt/packages/cli/src/commands/generate.js

42 lines
1022 B
JavaScript
Raw Normal View History

import consola from 'consola'
import { common } from '../options'
export default {
name: 'generate',
description: 'Generate a static web application (server-rendered)',
usage: 'generate <dir>',
options: {
...common,
build: {
type: 'boolean',
default: true,
description: 'Only generate pages for dynamic routes. Nuxt has to be built once before using this option'
},
modern: {
...common.modern,
description: 'Generate app in modern build (modern mode can be only client)',
prepare(cmd, options, argv) {
2018-11-08 09:18:56 +00:00
if (argv.modern !== undefined) {
options.modern = 'client'
}
}
}
},
async run(cmd) {
const argv = cmd.getArgv()
const generator = await cmd.getGenerator(
await cmd.getNuxt(
await cmd.getNuxtConfig(argv, { dev: false })
)
)
return generator.generate({
init: true,
build: argv.build
}).then(() => {
process.exit(0)
}).catch(err => consola.fatal(err))
}
}