mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
parent
c14471681c
commit
3db31abb05
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,6 +18,7 @@ distributions/*/LICENSE
|
|||||||
# Other
|
# Other
|
||||||
.nuxt*
|
.nuxt*
|
||||||
!.nuxtignore
|
!.nuxtignore
|
||||||
|
!.nuxtrc
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
# Dist folders
|
# Dist folders
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"destr": "^0.1.9",
|
"destr": "^0.1.9",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
|
"rc9": "^0.0.6",
|
||||||
"std-env": "^2.2.1"
|
"std-env": "^2.2.1"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@ -6,6 +6,7 @@ import dotenv from 'dotenv'
|
|||||||
import { clearRequireCache, scanRequireTree } from '@nuxt/utils'
|
import { clearRequireCache, scanRequireTree } from '@nuxt/utils'
|
||||||
import esm from 'esm'
|
import esm from 'esm'
|
||||||
import destr from 'destr'
|
import destr from 'destr'
|
||||||
|
import * as rc from 'rc9'
|
||||||
import { defaultNuxtConfigFile } from './config'
|
import { defaultNuxtConfigFile } from './config'
|
||||||
|
|
||||||
export async function loadNuxtConfig ({
|
export async function loadNuxtConfig ({
|
||||||
@ -71,7 +72,7 @@ export async function loadNuxtConfig ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't mutate options export
|
// Don't mutate options export
|
||||||
options = defu(configOverrides, options)
|
options = { ...options }
|
||||||
|
|
||||||
// Keep _nuxtConfigFile for watching
|
// Keep _nuxtConfigFile for watching
|
||||||
options._nuxtConfigFile = configFile
|
options._nuxtConfigFile = configFile
|
||||||
@ -87,6 +88,15 @@ export async function loadNuxtConfig ({
|
|||||||
options.rootDir = rootDir
|
options.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load Combine configs
|
||||||
|
// Priority: configOverrides > nuxtConfig > .nuxtrc > .nuxtrc (global)
|
||||||
|
options = defu(
|
||||||
|
configOverrides,
|
||||||
|
options,
|
||||||
|
rc.read({ name: '.nuxtrc', dir: options.rootDir }),
|
||||||
|
rc.readUser('.nuxtrc')
|
||||||
|
)
|
||||||
|
|
||||||
// Load env to options._env
|
// Load env to options._env
|
||||||
options._env = env
|
options._env = env
|
||||||
options._envConfig = envConfig
|
options._envConfig = envConfig
|
||||||
|
1
packages/config/test/fixtures/nuxtrc/.nuxtrc
vendored
Normal file
1
packages/config/test/fixtures/nuxtrc/.nuxtrc
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
rc.works=true
|
10
packages/config/test/load.test.js
Normal file
10
packages/config/test/load.test.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
import { resolve } from 'path'
|
||||||
|
import { loadNuxtConfig } from '../src/load'
|
||||||
|
|
||||||
|
describe('config: load', () => {
|
||||||
|
test('load local nuxtrc', async () => {
|
||||||
|
const config = await loadNuxtConfig({ rootDir: resolve(__dirname, 'fixtures/nuxtrc') })
|
||||||
|
expect(config.rc.works).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
21
yarn.lock
21
yarn.lock
@ -6184,6 +6184,13 @@ flat-cache@^2.0.1:
|
|||||||
rimraf "2.6.3"
|
rimraf "2.6.3"
|
||||||
write "1.0.3"
|
write "1.0.3"
|
||||||
|
|
||||||
|
flat@^5.0.0:
|
||||||
|
version "5.0.0"
|
||||||
|
resolved "https://registry.npmjs.org/flat/-/flat-5.0.0.tgz#dab7d71d60413becb0ac2de9bf4304495e3af6af"
|
||||||
|
integrity sha512-6KSMM+cHHzXC/hpldXApL2S8Uz+QZv+tq5o/L0KQYleoG+GcwrnIJhTWC7tCOiKQp8D/fIvryINU1OZCCwevjA==
|
||||||
|
dependencies:
|
||||||
|
is-buffer "~2.0.4"
|
||||||
|
|
||||||
flatted@^2.0.0:
|
flatted@^2.0.0:
|
||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
resolved "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
|
resolved "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
|
||||||
@ -7255,6 +7262,11 @@ is-buffer@^1.1.5:
|
|||||||
resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
|
resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
|
||||||
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
|
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
|
||||||
|
|
||||||
|
is-buffer@~2.0.4:
|
||||||
|
version "2.0.4"
|
||||||
|
resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623"
|
||||||
|
integrity sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==
|
||||||
|
|
||||||
is-callable@^1.1.4, is-callable@^1.1.5:
|
is-callable@^1.1.4, is-callable@^1.1.5:
|
||||||
version "1.1.5"
|
version "1.1.5"
|
||||||
resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab"
|
resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab"
|
||||||
@ -10960,6 +10972,15 @@ raw-body@2.4.0:
|
|||||||
iconv-lite "0.4.24"
|
iconv-lite "0.4.24"
|
||||||
unpipe "1.0.0"
|
unpipe "1.0.0"
|
||||||
|
|
||||||
|
rc9@^0.0.6:
|
||||||
|
version "0.0.6"
|
||||||
|
resolved "https://registry.npmjs.org/rc9/-/rc9-0.0.6.tgz#5943a94dcec5070093134203c8e4909157a4c235"
|
||||||
|
integrity sha512-zJ6/hL0BG2Hs9g/1EHVncgAhDDCO86zntU16fRbUPyAIIEnWPb4ojmoQE8KL4VuO4jMRyLa/DyxOicwr8sdWyw==
|
||||||
|
dependencies:
|
||||||
|
defu "^2.0.4"
|
||||||
|
destr "^0.1.9"
|
||||||
|
flat "^5.0.0"
|
||||||
|
|
||||||
react-is@^16.12.0:
|
react-is@^16.12.0:
|
||||||
version "16.13.1"
|
version "16.13.1"
|
||||||
resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
||||||
|
Loading…
Reference in New Issue
Block a user