From 745813d4db59f7981baa41ac79e9dcec7bd3990f Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Tue, 28 Nov 2023 20:48:20 +0000 Subject: [PATCH] fix ?v= and ?t= urls in vite for hbs and gjs --- packages/vite/src/hbs.ts | 4 ++-- packages/vite/src/template-tag.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/hbs.ts b/packages/vite/src/hbs.ts index f1e8354a4d..c1119743a9 100644 --- a/packages/vite/src/hbs.ts +++ b/packages/vite/src/hbs.ts @@ -35,7 +35,7 @@ export function hbs(): Plugin { switch (meta.type) { case 'template': - let input = readFileSync(id, 'utf8'); + let input = readFileSync(id.replace(/\.hbs\?.*/, '.hbs'), 'utf8'); let code = hbsToJS(input); return { code, @@ -111,7 +111,7 @@ async function maybeSynthesizeComponentJS(context: PluginContext, source: string }; } -const hbsFilter = createFilter('**/*.hbs'); +const hbsFilter = createFilter('**/*.hbs?(\\?)*'); function maybeRewriteHBS(resolution: ResolvedId) { if (!hbsFilter(resolution.id)) { diff --git a/packages/vite/src/template-tag.ts b/packages/vite/src/template-tag.ts index 04ca1e7aec..2eef9b57ec 100644 --- a/packages/vite/src/template-tag.ts +++ b/packages/vite/src/template-tag.ts @@ -3,7 +3,7 @@ import type { Plugin } from 'vite'; import { readFileSync } from 'fs'; import { Preprocessor } from 'content-tag'; -const gjsFilter = createFilter('**/*.gjs'); +const gjsFilter = createFilter('**/*.gjs?(\\?)*'); export function templateTag(): Plugin { let preprocessor = new Preprocessor(); @@ -44,7 +44,7 @@ export function templateTag(): Plugin { if (!gjsFilter(id)) { return null; } - return preprocessor.process(readFileSync(id, 'utf8'), id); + return preprocessor.process(readFileSync(id.replace(/\.gjs\?.*/, '.gjs'), 'utf8'), id); }, }; }