mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
57 lines
1.4 KiB
JavaScript
Executable File
57 lines
1.4 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
const parseArgs = require('minimist')
|
|
const consola = require('consola')
|
|
const { Nuxt, Builder, Generator } = require('..')
|
|
const { loadNuxtConfig } = require('./common/utils')
|
|
|
|
const argv = parseArgs(process.argv.slice(2), {
|
|
alias: {
|
|
h: 'help',
|
|
c: 'config-file',
|
|
s: 'spa',
|
|
u: 'universal'
|
|
},
|
|
boolean: ['h', 's', 'u', 'build'],
|
|
string: ['c'],
|
|
default: {
|
|
c: 'nuxt.config.js',
|
|
build: true
|
|
}
|
|
})
|
|
|
|
if (argv.help) {
|
|
process.stderr.write(`
|
|
Description
|
|
Generate a static web application (server-rendered)
|
|
Usage
|
|
$ nuxt generate <dir>
|
|
Options
|
|
--spa Launch in SPA mode
|
|
--universal Launch in Universal mode (default)
|
|
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
|
--help, -h Displays this message
|
|
--no-build Just run generate for faster builds when just dynamic routes changed. Nuxt build is needed before this command.
|
|
`)
|
|
process.exit(0)
|
|
}
|
|
|
|
const options = loadNuxtConfig(argv)
|
|
|
|
options.dev = false // Force production mode (no webpack middleware called)
|
|
|
|
const nuxt = new Nuxt(options)
|
|
const builder = new Builder(nuxt)
|
|
const generator = new Generator(nuxt, builder)
|
|
|
|
const generateOptions = {
|
|
init: true,
|
|
build: argv.build
|
|
}
|
|
|
|
generator
|
|
.generate(generateOptions)
|
|
.then(() => {
|
|
process.exit(0)
|
|
})
|
|
.catch(err => consola.fatal(err))
|