mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
Update commands
This commit is contained in:
parent
4d6b85cfdd
commit
bbf6ea2953
@ -13,6 +13,7 @@ const { resolve } = require('path')
|
|||||||
|
|
||||||
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
||||||
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
||||||
|
|
||||||
let options = {}
|
let options = {}
|
||||||
if (fs.existsSync(nuxtConfigFile)) {
|
if (fs.existsSync(nuxtConfigFile)) {
|
||||||
options = require(nuxtConfigFile)
|
options = require(nuxtConfigFile)
|
||||||
@ -20,11 +21,11 @@ if (fs.existsSync(nuxtConfigFile)) {
|
|||||||
if (typeof options.rootDir !== 'string') {
|
if (typeof options.rootDir !== 'string') {
|
||||||
options.rootDir = rootDir
|
options.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
options.dev = true // Add hot reloading and watching changes
|
options.dev = true // Add hot reloading and watching changes
|
||||||
|
|
||||||
new Nuxt(options)
|
const nuxt = new Nuxt(options)
|
||||||
.then((nuxt) => {
|
nuxt.build()
|
||||||
|
.then(() => {
|
||||||
const server = new Server(nuxt)
|
const server = new Server(nuxt)
|
||||||
.listen(process.env.PORT || process.env.npm_package_config_nuxt_port, process.env.HOST || process.env.npm_package_config_nuxt_host)
|
.listen(process.env.PORT || process.env.npm_package_config_nuxt_port, process.env.HOST || process.env.npm_package_config_nuxt_host)
|
||||||
listenOnConfigChanges(nuxt, server)
|
listenOnConfigChanges(nuxt, server)
|
||||||
@ -46,7 +47,7 @@ function listenOnConfigChanges (nuxt, server) {
|
|||||||
options.rootDir = rootDir
|
options.rootDir = rootDir
|
||||||
nuxt.close()
|
nuxt.close()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return new Nuxt(options)
|
return new Nuxt(options).build()
|
||||||
})
|
})
|
||||||
.then((nuxt) => {
|
.then((nuxt) => {
|
||||||
server.nuxt = nuxt
|
server.nuxt = nuxt
|
||||||
|
@ -9,6 +9,7 @@ const { resolve } = require('path')
|
|||||||
|
|
||||||
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
||||||
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
||||||
|
|
||||||
let options = {}
|
let options = {}
|
||||||
if (fs.existsSync(nuxtConfigFile)) {
|
if (fs.existsSync(nuxtConfigFile)) {
|
||||||
options = require(nuxtConfigFile)
|
options = require(nuxtConfigFile)
|
||||||
@ -16,14 +17,11 @@ if (fs.existsSync(nuxtConfigFile)) {
|
|||||||
if (typeof options.rootDir !== 'string') {
|
if (typeof options.rootDir !== 'string') {
|
||||||
options.rootDir = rootDir
|
options.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
options._build = false // nuxt.generate() will call nuxt.build() itself
|
|
||||||
options._renderer = false // let nuxt.generate() create the vue renderer
|
|
||||||
options.dev = false // Force production mode (no webpack middlewares called)
|
options.dev = false // Force production mode (no webpack middlewares called)
|
||||||
|
|
||||||
console.log('[nuxt] Generating...')
|
console.log('[nuxt] Generating...')
|
||||||
new Nuxt(options)
|
const nuxt = new Nuxt(options)
|
||||||
.then((nuxt) => nuxt.generate())
|
nuxt.generate()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log('[nuxt] Generate done')
|
console.log('[nuxt] Generate done')
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,7 @@ const { resolve } = require('path')
|
|||||||
|
|
||||||
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
||||||
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
||||||
|
|
||||||
let options = {}
|
let options = {}
|
||||||
if (fs.existsSync(nuxtConfigFile)) {
|
if (fs.existsSync(nuxtConfigFile)) {
|
||||||
options = require(nuxtConfigFile)
|
options = require(nuxtConfigFile)
|
||||||
@ -14,16 +15,12 @@ if (fs.existsSync(nuxtConfigFile)) {
|
|||||||
if (typeof options.rootDir !== 'string') {
|
if (typeof options.rootDir !== 'string') {
|
||||||
options.rootDir = rootDir
|
options.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
options._build = false // Disable building
|
|
||||||
options.dev = false // Force production mode (no webpack middlewares called)
|
options.dev = false // Force production mode (no webpack middlewares called)
|
||||||
|
|
||||||
new Nuxt(options)
|
const nuxt = new Nuxt(options)
|
||||||
.then((nuxt) => {
|
|
||||||
new Server(nuxt)
|
new Server(nuxt)
|
||||||
.listen(process.env.PORT || process.env.npm_package_config_nuxt_port, process.env.HOST || process.env.npm_package_config_nuxt_host)
|
.listen(
|
||||||
})
|
process.env.PORT || process.env.npm_package_config_nuxt_port,
|
||||||
.catch((err) => {
|
process.env.HOST || process.env.npm_package_config_nuxt_host
|
||||||
console.error(err)
|
)
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
|
Loading…
Reference in New Issue
Block a user