mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): respect layer order for other layer plugins (#23148)
This commit is contained in:
parent
2a21059495
commit
a4cf8a0c24
@ -126,9 +126,7 @@ async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve plugins, first extended layers and then base
|
// Resolve plugins, first extended layers and then base
|
||||||
app.plugins = [
|
app.plugins = []
|
||||||
...nuxt.options.plugins.map(normalizePlugin)
|
|
||||||
]
|
|
||||||
for (const config of nuxt.options._layers.map(layer => layer.config).reverse()) {
|
for (const config of nuxt.options._layers.map(layer => layer.config).reverse()) {
|
||||||
app.plugins.push(...[
|
app.plugins.push(...[
|
||||||
...(config.plugins || []),
|
...(config.plugins || []),
|
||||||
@ -141,6 +139,14 @@ async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
|
|||||||
].map(plugin => normalizePlugin(plugin as NuxtPlugin)))
|
].map(plugin => normalizePlugin(plugin as NuxtPlugin)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add back plugins not specified in layers or user config
|
||||||
|
for (const p of nuxt.options.plugins) {
|
||||||
|
const plugin = normalizePlugin(p)
|
||||||
|
if (!app.plugins.some(p => p.src === plugin.src)) {
|
||||||
|
app.plugins.unshift(plugin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize and de-duplicate plugins and middleware
|
// Normalize and de-duplicate plugins and middleware
|
||||||
app.middleware = uniqueBy(await resolvePaths(app.middleware, 'path'), 'name')
|
app.middleware = uniqueBy(await resolvePaths(app.middleware, 'path'), 'name')
|
||||||
app.plugins = uniqueBy(await resolvePaths(app.plugins, 'src'), 'src')
|
app.plugins = uniqueBy(await resolvePaths(app.plugins, 'src'), 'src')
|
||||||
|
Loading…
Reference in New Issue
Block a user