diff --git a/src/node/utils/transformUtils.ts b/src/node/utils/transformUtils.ts index 34280a019c92d4..d68d17ad8f28c8 100644 --- a/src/node/utils/transformUtils.ts +++ b/src/node/utils/transformUtils.ts @@ -36,18 +36,14 @@ export async function transformIndexHtml( apply: 'pre' | 'post', isBuild = false ) { - const trans = transforms - .map((t) => { - return typeof t === 'function' && apply === 'post' - ? t - : t.apply === apply - ? t.transform - : undefined - }) - .filter(Boolean) let code = html - for (const transform of trans) { - code = await transform!({ isBuild, code }) + for (let t of transforms) { + if (typeof t === 'function') { + t = { apply: 'post', transform: t } + } + if (t.apply === apply) { + code = await t.transform({ isBuild, code }) + } } return code }