fix(config): define once default nuxt config filename (#4814)

This commit is contained in:
Kevin Marrec 2019-01-22 20:52:43 +01:00 committed by Pooya Parsa
parent 675e3b6e99
commit 06a18ca09e
5 changed files with 10 additions and 9 deletions

View File

@ -1,7 +1,6 @@
import { defaultNuxtConfigFile } from '@nuxt/config'
import { normalizeArg } from '../utils' import { normalizeArg } from '../utils'
const defaultConfigFile = `nuxt.config${process.env.NUXT_TS === 'true' ? '.ts' : '.js'}`
export default { export default {
spa: { spa: {
alias: 's', alias: 's',
@ -16,8 +15,8 @@ export default {
'config-file': { 'config-file': {
alias: 'c', alias: 'c',
type: 'string', type: 'string',
default: defaultConfigFile, default: defaultNuxtConfigFile,
description: `Path to Nuxt.js config file (default: \`${defaultConfigFile}\`)` description: `Path to Nuxt.js config file (default: \`${defaultNuxtConfigFile}\`)`
}, },
modern: { modern: {
alias: 'm', alias: 'm',

View File

@ -3,7 +3,7 @@ import { existsSync } from 'fs'
import consola from 'consola' import consola from 'consola'
import esm from 'esm' import esm from 'esm'
import defaultsDeep from 'lodash/defaultsDeep' import defaultsDeep from 'lodash/defaultsDeep'
import { getDefaultNuxtConfig } from '@nuxt/config' import { defaultNuxtConfigFile, getDefaultNuxtConfig } from '@nuxt/config'
import boxen from 'boxen' import boxen from 'boxen'
import chalk from 'chalk' import chalk from 'chalk'
import prettyBytes from 'pretty-bytes' import prettyBytes from 'pretty-bytes'
@ -54,7 +54,7 @@ export async function loadNuxtConfig(argv) {
// Keep _nuxtConfigFile for watching // Keep _nuxtConfigFile for watching
options._nuxtConfigFile = nuxtConfigFile options._nuxtConfigFile = nuxtConfigFile
} else if (argv['config-file'] !== 'nuxt.config.js') { } else if (argv['config-file'] !== defaultNuxtConfigFile) {
consola.fatal('Could not load config file: ' + argv['config-file']) consola.fatal('Could not load config file: ' + argv['config-file'])
} }
if (typeof options.rootDir !== 'string') { if (typeof options.rootDir !== 'string') {

View File

@ -10,6 +10,8 @@ import router from './router'
import server from './server' import server from './server'
import cli from './cli' import cli from './cli'
export const defaultNuxtConfigFile = `nuxt.config${process.env.NUXT_TS === 'true' ? '.ts' : '.js'}`
export function getDefaultNuxtConfig(options = {}) { export function getDefaultNuxtConfig(options = {}) {
if (!options.env) { if (!options.env) {
options.env = process.env options.env = process.env

View File

@ -1,2 +1,2 @@
export { getDefaultNuxtConfig } from './config' export { defaultNuxtConfigFile, getDefaultNuxtConfig } from './config'
export { getNuxtConfig } from './options' export { getNuxtConfig } from './options'

View File

@ -7,7 +7,7 @@ import isObject from 'lodash/isObject'
import uniq from 'lodash/uniq' import uniq from 'lodash/uniq'
import consola from 'consola' import consola from 'consola'
import { guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule } from '@nuxt/utils' import { guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule } from '@nuxt/utils'
import { getDefaultNuxtConfig } from './config' import { defaultNuxtConfigFile, getDefaultNuxtConfig } from './config'
export function getNuxtConfig(_options) { export function getNuxtConfig(_options) {
// Prevent duplicate calls // Prevent duplicate calls
@ -84,7 +84,7 @@ export function getNuxtConfig(_options) {
// Default value for _nuxtConfigFile // Default value for _nuxtConfigFile
if (!options._nuxtConfigFile) { if (!options._nuxtConfigFile) {
options._nuxtConfigFile = path.resolve(options.rootDir, 'nuxt.config.js') options._nuxtConfigFile = path.resolve(options.rootDir, defaultNuxtConfigFile)
} }
// Watch for _nuxtConfigFile changes // Watch for _nuxtConfigFile changes