From c177354633de9b2e02a8a5c61c9bcb4470332662 Mon Sep 17 00:00:00 2001 From: Alex M Date: Wed, 19 Apr 2017 17:01:26 -0300 Subject: [PATCH] Add support to --config-file to nuxt-dev --- bin/nuxt-dev | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 9b847bcd08..0c2c1157a9 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -10,9 +10,25 @@ var fs = require('fs') var Nuxt = require('../') var chokidar = require('chokidar') var resolve = require('path').resolve +var without = require('lodash').without + +var nuxtConfigFileName = 'nuxt.config.js' + +// --config-file option +var indexOfConfig = false +if (process.argv.indexOf('--config-file') !== -1) { + indexOfConfig = process.argv.indexOf('--config-file') +} else if (process.argv.indexOf('-c') !== -1) { + indexOfConfig = process.argv.indexOf('-c') +} + +if (indexOfConfig !== false) { + nuxtConfigFileName = process.argv.slice(indexOfConfig)[1] + process.argv = without(process.argv, '--config-file', '-c', nuxtConfigFileName) +} var rootDir = resolve(process.argv.slice(2)[0] || '.') -var nuxtConfigFile = resolve(rootDir, 'nuxt.config.js') +var nuxtConfigFile = resolve(rootDir, nuxtConfigFileName) var options = {} if (fs.existsSync(nuxtConfigFile)) { @@ -62,7 +78,7 @@ function listenOnConfigChanges (nuxt, server) { process.exit(1) }) }, 200) - var nuxtConfigFile = resolve(rootDir, 'nuxt.config.js') + var nuxtConfigFile = resolve(rootDir, nuxtConfigFileName) chokidar.watch(nuxtConfigFile, Object.assign({}, nuxt.options.watchers.chokidar, { ignoreInitial: true })) .on('all', build) }