@nuxt/docs-nightly 4.2.1-29372339.038f9d9f → 4.2.1-29372549.6b6ea5fa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -80,27 +80,46 @@ Nuxt uses [unjs/c12](https://github.com/unjs/c12) and [unjs/giget](https://githu
|
|
|
80
80
|
|
|
81
81
|
## Layer Priority
|
|
82
82
|
|
|
83
|
-
When using multiple layers, it's important to understand
|
|
83
|
+
When using multiple layers, it's important to understand the override order. Layers with **higher priority** override layers with lower priority when they define the same files or components.
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
The priority order from highest to lowest is:
|
|
86
|
+
|
|
87
|
+
1. **Your project files** - always have the highest priority
|
|
88
|
+
2. **Auto-scanned layers** from `~~/layers` directory - sorted alphabetically (Z has higher priority than A)
|
|
89
|
+
3. **Layers in `extends`** config - first entry has higher priority than second
|
|
90
|
+
|
|
91
|
+
### When to Use Each
|
|
92
|
+
|
|
93
|
+
- **`extends`** - Use for external dependencies (npm packages, remote repositories) or layers outside your project directory
|
|
94
|
+
- **`~~/layers` directory** - Use for local layers that are part of your project
|
|
95
|
+
|
|
96
|
+
::tip
|
|
97
|
+
If you need to control the order of auto-scanned layers, you can prefix them with numbers: `~/layers/1.z-layer`, `~/layers/2.a-layer`. This way `2.a-layer` will have higher priority than `1.z-layer`.
|
|
98
|
+
::
|
|
99
|
+
|
|
100
|
+
### Example
|
|
88
101
|
|
|
89
102
|
```ts [nuxt.config.ts]
|
|
90
103
|
export default defineNuxtConfig({
|
|
91
104
|
extends: [
|
|
92
|
-
//
|
|
105
|
+
// Local layer outside the project
|
|
93
106
|
'../base',
|
|
94
|
-
//
|
|
107
|
+
// NPM package
|
|
95
108
|
'@my-themes/awesome',
|
|
96
|
-
//
|
|
109
|
+
// Remote repository
|
|
97
110
|
'github:my-themes/awesome#v1',
|
|
98
111
|
],
|
|
99
|
-
// Your project has the highest priority
|
|
100
112
|
})
|
|
101
113
|
```
|
|
102
114
|
|
|
103
|
-
|
|
115
|
+
If you also have `~~/layers/custom`, the priority order is:
|
|
116
|
+
- Your project files (highest)
|
|
117
|
+
- `~~/layers/custom`
|
|
118
|
+
- `../base`
|
|
119
|
+
- `@my-themes/awesome`
|
|
120
|
+
- `github:my-themes/awesome#v1` (lowest)
|
|
121
|
+
|
|
122
|
+
This means your project files will override any layer, and `~~/layers/custom` will override anything in `extends`.
|
|
104
123
|
|
|
105
124
|
::read-more{to="/docs/4.x/guide/going-further/layers"}
|
|
106
125
|
Read more about layers in the **Layer Author Guide**.
|
|
@@ -68,29 +68,46 @@ Additionally, certain other files in the layer directory will be auto-scanned an
|
|
|
68
68
|
|
|
69
69
|
## Layer Priority
|
|
70
70
|
|
|
71
|
-
When extending from multiple layers, it's important to understand the priority
|
|
71
|
+
When extending from multiple layers, it's important to understand the override order. Layers with **higher priority** override layers with lower priority when they define the same files or components.
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
2. **Auto-scanned local layers** from `~~/layers` directory in alphabetical order (Z overrides A)
|
|
75
|
-
3. **Your project** has the highest priority in the stack - it will always override other layers
|
|
73
|
+
The priority order from highest to lowest is:
|
|
76
74
|
|
|
77
|
-
|
|
75
|
+
1. **Your project files** - always have the highest priority
|
|
76
|
+
2. **Auto-scanned layers** from `~~/layers` directory - sorted alphabetically (Z has higher priority than A)
|
|
77
|
+
3. **Layers in `extends`** config - first entry has higher priority than second
|
|
78
|
+
|
|
79
|
+
### When to Use Each
|
|
80
|
+
|
|
81
|
+
- **`extends`** - Use for external dependencies (npm packages, remote repositories) or layers outside your project directory
|
|
82
|
+
- **`~~/layers` directory** - Use for local layers that are part of your project
|
|
83
|
+
|
|
84
|
+
::tip
|
|
85
|
+
If you need to control the order of auto-scanned layers, you can prefix them with numbers: `~/layers/1.z-layer`, `~/layers/2.a-layer`. This way `2.a-layer` will have higher priority than `1.z-layer`.
|
|
86
|
+
::
|
|
87
|
+
|
|
88
|
+
### Example
|
|
78
89
|
|
|
79
90
|
```ts [nuxt.config.ts]
|
|
80
91
|
export default defineNuxtConfig({
|
|
81
92
|
extends: [
|
|
82
|
-
//
|
|
83
|
-
'
|
|
84
|
-
//
|
|
85
|
-
'
|
|
86
|
-
//
|
|
87
|
-
'
|
|
93
|
+
// Local layer outside the project
|
|
94
|
+
'../base',
|
|
95
|
+
// NPM package
|
|
96
|
+
'@my-themes/awesome',
|
|
97
|
+
// Remote repository
|
|
98
|
+
'github:my-themes/awesome#v1',
|
|
88
99
|
],
|
|
89
|
-
// Your project has the highest priority
|
|
90
100
|
})
|
|
91
101
|
```
|
|
92
102
|
|
|
93
|
-
If you also have
|
|
103
|
+
If you also have `~~/layers/custom`, the priority order is:
|
|
104
|
+
- Your project files (highest)
|
|
105
|
+
- `~~/layers/custom`
|
|
106
|
+
- `../base`
|
|
107
|
+
- `@my-themes/awesome`
|
|
108
|
+
- `github:my-themes/awesome#v1` (lowest)
|
|
109
|
+
|
|
110
|
+
This means your project files will override any layer, and `~~/layers/custom` will override anything in `extends`.
|
|
94
111
|
|
|
95
112
|
## Starter Template
|
|
96
113
|
|