diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 91bed6f878..b11816cd58 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -13,6 +13,7 @@ const { resolve } = require('path') const rootDir = resolve(process.argv.slice(2)[0] || '.') const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js') + let options = {} if (fs.existsSync(nuxtConfigFile)) { options = require(nuxtConfigFile) @@ -20,11 +21,11 @@ if (fs.existsSync(nuxtConfigFile)) { if (typeof options.rootDir !== 'string') { options.rootDir = rootDir } - options.dev = true // Add hot reloading and watching changes -new Nuxt(options) -.then((nuxt) => { +const nuxt = new Nuxt(options) +nuxt.build() +.then(() => { 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) listenOnConfigChanges(nuxt, server) @@ -46,7 +47,7 @@ function listenOnConfigChanges (nuxt, server) { options.rootDir = rootDir nuxt.close() .then(() => { - return new Nuxt(options) + return new Nuxt(options).build() }) .then((nuxt) => { server.nuxt = nuxt diff --git a/bin/nuxt-generate b/bin/nuxt-generate index d1f9cf9b6e..5d0272cd77 100755 --- a/bin/nuxt-generate +++ b/bin/nuxt-generate @@ -9,6 +9,7 @@ const { resolve } = require('path') const rootDir = resolve(process.argv.slice(2)[0] || '.') const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js') + let options = {} if (fs.existsSync(nuxtConfigFile)) { options = require(nuxtConfigFile) @@ -16,14 +17,11 @@ if (fs.existsSync(nuxtConfigFile)) { if (typeof options.rootDir !== 'string') { 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) console.log('[nuxt] Generating...') -new Nuxt(options) -.then((nuxt) => nuxt.generate()) +const nuxt = new Nuxt(options) +nuxt.generate() .then(() => { console.log('[nuxt] Generate done') }) diff --git a/bin/nuxt-start b/bin/nuxt-start index 54558258b5..223b180b9b 100755 --- a/bin/nuxt-start +++ b/bin/nuxt-start @@ -7,6 +7,7 @@ const { resolve } = require('path') const rootDir = resolve(process.argv.slice(2)[0] || '.') const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js') + let options = {} if (fs.existsSync(nuxtConfigFile)) { options = require(nuxtConfigFile) @@ -14,16 +15,12 @@ if (fs.existsSync(nuxtConfigFile)) { if (typeof options.rootDir !== 'string') { options.rootDir = rootDir } - -options._build = false // Disable building options.dev = false // Force production mode (no webpack middlewares called) -new Nuxt(options) -.then((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) -}) -.catch((err) => { - console.error(err) - process.exit(1) -}) +const nuxt = new Nuxt(options) + +new Server(nuxt) +.listen( + process.env.PORT || process.env.npm_package_config_nuxt_port, + process.env.HOST || process.env.npm_package_config_nuxt_host +)