feat(config): add configOverrides for loadNuxt and loadNuxtConf… (#7263)

This commit is contained in:
Xin Du (Clark) 2020-04-24 09:59:56 +01:00 committed by GitHub
parent 5d5d951772
commit 1ce8041abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 415 additions and 489 deletions

View File

@ -12,6 +12,7 @@
"dependencies": {
"@nuxt/utils": "2.12.1",
"consola": "^2.11.3",
"defu": "^2.0.2",
"esm": "^3.2.25",
"std-env": "^2.2.1"
},

View File

@ -1,4 +1,5 @@
import path from 'path'
import defu from 'defu'
import consola from 'consola'
import { clearRequireCache, scanRequireTree } from '@nuxt/utils'
import esm from 'esm'
@ -7,7 +8,8 @@ import { defaultNuxtConfigFile } from './config'
export async function loadNuxtConfig ({
rootDir = '.',
configFile = defaultNuxtConfigFile,
configContext = {}
configContext = {},
configOverrides = {}
} = {}) {
rootDir = path.resolve(rootDir)
@ -48,7 +50,7 @@ export async function loadNuxtConfig ({
}
// Don't mutate options export
options = Object.assign({}, options)
options = defu(configOverrides, options)
// Keep _nuxtConfigFile for watching
options._nuxtConfigFile = configFile

View File

@ -1,7 +1,7 @@
import path from 'path'
import fs from 'fs'
import defaultsDeep from 'lodash/defaultsDeep'
import defaults from 'lodash/defaults'
import defu from 'defu'
import pick from 'lodash/pick'
import uniq from 'lodash/uniq'
import consola from 'consola'
@ -237,7 +237,7 @@ export function getNuxtConfig (_options) {
// Apply default hash to CSP option
if (options.render.csp) {
options.render.csp = defaults({}, options.render.csp, {
options.render.csp = defu(options.render.csp, {
hashAlgorithm: 'sha256',
allowedSources: undefined,
policies: undefined,

893
yarn.lock

File diff suppressed because it is too large Load Diff