From 024773f33dbb2d73504dfa3844b50624690be788 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Mon, 4 Mar 2024 18:12:21 +0100 Subject: [PATCH] feat(vite): align path is template vars in angular components --- vite.config.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index ed2653e27f6..f1ff163188c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -84,10 +84,11 @@ function angularHtmlImport() { name: 'transform-angular-html', async transform(src, id) { if (htmlComponentFile.test(id)) { - const idParts = id.split('/public/'); - const path = idParts[idParts.length - 1]; + const cleanId = id.replace(/\?inline$/, ''); + const idParts = cleanId.split('/public/'); + const path = `public/${idParts[idParts.length - 1]}`; const html = JSON.stringify(src); - const result = `const path = 'public/${path}'; + const result = `const path = '${path}'; const htmlTemplate = ${html}; angular.module('ng').run(['$templateCache', c => { c.put(path, htmlTemplate) }]); export default path;`; return { code: result, map: null };