mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
feat(config): add configOverrides for loadNuxt and loadNuxtConf… (#7263)
This commit is contained in:
parent
5d5d951772
commit
1ce8041abe
@ -12,6 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/utils": "2.12.1",
|
"@nuxt/utils": "2.12.1",
|
||||||
"consola": "^2.11.3",
|
"consola": "^2.11.3",
|
||||||
|
"defu": "^2.0.2",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"std-env": "^2.2.1"
|
"std-env": "^2.2.1"
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import defu from 'defu'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { clearRequireCache, scanRequireTree } from '@nuxt/utils'
|
import { clearRequireCache, scanRequireTree } from '@nuxt/utils'
|
||||||
import esm from 'esm'
|
import esm from 'esm'
|
||||||
@ -7,7 +8,8 @@ import { defaultNuxtConfigFile } from './config'
|
|||||||
export async function loadNuxtConfig ({
|
export async function loadNuxtConfig ({
|
||||||
rootDir = '.',
|
rootDir = '.',
|
||||||
configFile = defaultNuxtConfigFile,
|
configFile = defaultNuxtConfigFile,
|
||||||
configContext = {}
|
configContext = {},
|
||||||
|
configOverrides = {}
|
||||||
} = {}) {
|
} = {}) {
|
||||||
rootDir = path.resolve(rootDir)
|
rootDir = path.resolve(rootDir)
|
||||||
|
|
||||||
@ -48,7 +50,7 @@ export async function loadNuxtConfig ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't mutate options export
|
// Don't mutate options export
|
||||||
options = Object.assign({}, options)
|
options = defu(configOverrides, options)
|
||||||
|
|
||||||
// Keep _nuxtConfigFile for watching
|
// Keep _nuxtConfigFile for watching
|
||||||
options._nuxtConfigFile = configFile
|
options._nuxtConfigFile = configFile
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import defaultsDeep from 'lodash/defaultsDeep'
|
import defaultsDeep from 'lodash/defaultsDeep'
|
||||||
import defaults from 'lodash/defaults'
|
import defu from 'defu'
|
||||||
import pick from 'lodash/pick'
|
import pick from 'lodash/pick'
|
||||||
import uniq from 'lodash/uniq'
|
import uniq from 'lodash/uniq'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
@ -237,7 +237,7 @@ export function getNuxtConfig (_options) {
|
|||||||
|
|
||||||
// Apply default hash to CSP option
|
// Apply default hash to CSP option
|
||||||
if (options.render.csp) {
|
if (options.render.csp) {
|
||||||
options.render.csp = defaults({}, options.render.csp, {
|
options.render.csp = defu(options.render.csp, {
|
||||||
hashAlgorithm: 'sha256',
|
hashAlgorithm: 'sha256',
|
||||||
allowedSources: undefined,
|
allowedSources: undefined,
|
||||||
policies: undefined,
|
policies: undefined,
|
||||||
|
Loading…
Reference in New Issue
Block a user