mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +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
|
||||
app.plugins = [
|
||||
...nuxt.options.plugins.map(normalizePlugin)
|
||||
]
|
||||
app.plugins = []
|
||||
for (const config of nuxt.options._layers.map(layer => layer.config).reverse()) {
|
||||
app.plugins.push(...[
|
||||
...(config.plugins || []),
|
||||
@ -141,6 +139,14 @@ async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
|
||||
].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
|
||||
app.middleware = uniqueBy(await resolvePaths(app.middleware, 'path'), 'name')
|
||||
app.plugins = uniqueBy(await resolvePaths(app.plugins, 'src'), 'src')
|
||||
|
Loading…
Reference in New Issue
Block a user