mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Add support to --config-file to nuxt-dev
This commit is contained in:
parent
0bea10b857
commit
c177354633
20
bin/nuxt-dev
20
bin/nuxt-dev
@ -10,9 +10,25 @@ var fs = require('fs')
|
|||||||
var Nuxt = require('../')
|
var Nuxt = require('../')
|
||||||
var chokidar = require('chokidar')
|
var chokidar = require('chokidar')
|
||||||
var resolve = require('path').resolve
|
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 rootDir = resolve(process.argv.slice(2)[0] || '.')
|
||||||
var nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
var nuxtConfigFile = resolve(rootDir, nuxtConfigFileName)
|
||||||
|
|
||||||
var options = {}
|
var options = {}
|
||||||
if (fs.existsSync(nuxtConfigFile)) {
|
if (fs.existsSync(nuxtConfigFile)) {
|
||||||
@ -62,7 +78,7 @@ function listenOnConfigChanges (nuxt, server) {
|
|||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
}, 200)
|
}, 200)
|
||||||
var nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
var nuxtConfigFile = resolve(rootDir, nuxtConfigFileName)
|
||||||
chokidar.watch(nuxtConfigFile, Object.assign({}, nuxt.options.watchers.chokidar, { ignoreInitial: true }))
|
chokidar.watch(nuxtConfigFile, Object.assign({}, nuxt.options.watchers.chokidar, { ignoreInitial: true }))
|
||||||
.on('all', build)
|
.on('all', build)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user