Skip to content

Commit

Permalink
chore: enable plugin order
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Aug 12, 2024
1 parent d76d483 commit f504bcf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/vite/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,21 @@ export function getSortedPluginsByHook<K extends keyof Plugin>(
const sortedPlugins: Plugin[] = []
// Use indexes to track and insert the ordered plugins directly in the
// resulting array to avoid creating 3 extra temporary arrays per hook
const pre = 0;
let normal = 0;
// post = 0
let pre = 0,
normal = 0,
post = 0
for (const plugin of plugins) {
const hook = plugin[hookName]
if (hook) {
if (typeof hook === 'object') {
// if (hook.order === 'pre') {
// sortedPlugins.splice(pre++, 0, plugin)
// continue
// }
// if (hook.order === 'post') {
// sortedPlugins.splice(pre + normal + post++, 0, plugin)
// continue
// }
if (hook.order === 'pre') {
sortedPlugins.splice(pre++, 0, plugin)
continue
}
if (hook.order === 'post') {
sortedPlugins.splice(pre + normal + post++, 0, plugin)
continue
}
}
sortedPlugins.splice(pre + normal++, 0, plugin)
}
Expand Down

0 comments on commit f504bcf

Please sign in to comment.