Skip to content

Commit

Permalink
also reorders plugins in SSG mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vejja committed Oct 29, 2023
1 parent 9d26803 commit 076f819
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ const registerSecurityNitroPlugins = (
new URL('./runtime/nitro/plugins', import.meta.url)
)
)
// SSR: Reorder plugins in Nitro options
nitro.options.plugins.sort((a, b) => {
if (a.startsWith(securityPluginsPrefix)) {
if (b.startsWith(securityPluginsPrefix)) {
Expand All @@ -309,5 +310,23 @@ const registerSecurityNitroPlugins = (
}
}
})
// SSG: Reorder plugins in Nitro hook
nitro.hooks.hook('prerender:config', config => {
config.plugins?.sort((a, b) => {
if (a?.startsWith(securityPluginsPrefix)) {
if (b?.startsWith(securityPluginsPrefix)) {
return 0
} else {
return 1
}
} else {
if (b?.startsWith(securityPluginsPrefix)) {
return -1
} else {
return 0
}
}
})
})
})
}

0 comments on commit 076f819

Please sign in to comment.