mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
fix(config): define once default nuxt config filename (#4814)
This commit is contained in:
parent
675e3b6e99
commit
06a18ca09e
@ -1,7 +1,6 @@
|
||||
import { defaultNuxtConfigFile } from '@nuxt/config'
|
||||
import { normalizeArg } from '../utils'
|
||||
|
||||
const defaultConfigFile = `nuxt.config${process.env.NUXT_TS === 'true' ? '.ts' : '.js'}`
|
||||
|
||||
export default {
|
||||
spa: {
|
||||
alias: 's',
|
||||
@ -16,8 +15,8 @@ export default {
|
||||
'config-file': {
|
||||
alias: 'c',
|
||||
type: 'string',
|
||||
default: defaultConfigFile,
|
||||
description: `Path to Nuxt.js config file (default: \`${defaultConfigFile}\`)`
|
||||
default: defaultNuxtConfigFile,
|
||||
description: `Path to Nuxt.js config file (default: \`${defaultNuxtConfigFile}\`)`
|
||||
},
|
||||
modern: {
|
||||
alias: 'm',
|
||||
|
@ -3,7 +3,7 @@ import { existsSync } from 'fs'
|
||||
import consola from 'consola'
|
||||
import esm from 'esm'
|
||||
import defaultsDeep from 'lodash/defaultsDeep'
|
||||
import { getDefaultNuxtConfig } from '@nuxt/config'
|
||||
import { defaultNuxtConfigFile, getDefaultNuxtConfig } from '@nuxt/config'
|
||||
import boxen from 'boxen'
|
||||
import chalk from 'chalk'
|
||||
import prettyBytes from 'pretty-bytes'
|
||||
@ -54,7 +54,7 @@ export async function loadNuxtConfig(argv) {
|
||||
|
||||
// Keep _nuxtConfigFile for watching
|
||||
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'])
|
||||
}
|
||||
if (typeof options.rootDir !== 'string') {
|
||||
|
@ -10,6 +10,8 @@ import router from './router'
|
||||
import server from './server'
|
||||
import cli from './cli'
|
||||
|
||||
export const defaultNuxtConfigFile = `nuxt.config${process.env.NUXT_TS === 'true' ? '.ts' : '.js'}`
|
||||
|
||||
export function getDefaultNuxtConfig(options = {}) {
|
||||
if (!options.env) {
|
||||
options.env = process.env
|
||||
|
@ -1,2 +1,2 @@
|
||||
export { getDefaultNuxtConfig } from './config'
|
||||
export { defaultNuxtConfigFile, getDefaultNuxtConfig } from './config'
|
||||
export { getNuxtConfig } from './options'
|
||||
|
@ -7,7 +7,7 @@ import isObject from 'lodash/isObject'
|
||||
import uniq from 'lodash/uniq'
|
||||
import consola from 'consola'
|
||||
import { guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule } from '@nuxt/utils'
|
||||
import { getDefaultNuxtConfig } from './config'
|
||||
import { defaultNuxtConfigFile, getDefaultNuxtConfig } from './config'
|
||||
|
||||
export function getNuxtConfig(_options) {
|
||||
// Prevent duplicate calls
|
||||
@ -84,7 +84,7 @@ export function getNuxtConfig(_options) {
|
||||
|
||||
// Default value for _nuxtConfigFile
|
||||
if (!options._nuxtConfigFile) {
|
||||
options._nuxtConfigFile = path.resolve(options.rootDir, 'nuxt.config.js')
|
||||
options._nuxtConfigFile = path.resolve(options.rootDir, defaultNuxtConfigFile)
|
||||
}
|
||||
|
||||
// Watch for _nuxtConfigFile changes
|
||||
|
Loading…
Reference in New Issue
Block a user