mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
docs: add info about merging strategy in app config (#21462)
This commit is contained in:
parent
02ba4b30ac
commit
4fd756bae2
@ -91,3 +91,32 @@ declare module 'nuxt/schema' {
|
||||
// It is always important to ensure you import/export something when augmenting a type
|
||||
export {}
|
||||
```
|
||||
|
||||
### App Config Merging Strategy in Layers
|
||||
|
||||
Nuxt uses a custom merging strategy for the `AppConfig` within the layers of your application.
|
||||
This strategy is implemented using a [Function Merger](https://github.com/unjs/defu#function-merger), which allows defining a custom merging strategy for every key in `app.config` that has an array as value.
|
||||
|
||||
::alert{type=warning}
|
||||
The Function Merger should only be used in the base `app.config` of your application.
|
||||
::
|
||||
|
||||
Here's an example of how you can use:
|
||||
|
||||
::code-group
|
||||
|
||||
```ts [layer/app.config.ts]
|
||||
export default defineAppConfig({
|
||||
// Default array value
|
||||
array: ['hello'],
|
||||
})
|
||||
```
|
||||
|
||||
```ts [app.config.ts]
|
||||
export default defineAppConfig({
|
||||
// Overwrite default array value by using a merger function
|
||||
array: () => ['bonjour'],
|
||||
})
|
||||
```
|
||||
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user