From 7fb60cc83abae7a98ad24d19d8507727fa076a79 Mon Sep 17 00:00:00 2001 From: Skiyee <319619193@qq.com> Date: Mon, 5 Aug 2024 23:33:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=9A=80=20=E9=80=82=E9=85=8DHBuild?= =?UTF-8?q?er=E5=88=9B=E5=BB=BA=E7=9A=84=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 4 ++-- src/root.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index c6f3df7..5f3b590 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,11 +18,11 @@ export default function UniKuRoot(): Plugin { name: 'vite-plugin-uni-root', enforce: 'pre', async transform(code, id) { - const filterMain = createFilter(['src/main.(ts|js)', 'main.(ts|js)']) + const filterMain = createFilter(`${rootPath}/main.(ts|js)`) if (filterMain(id)) return registerKuApp(code) - const filterKuRoot = createFilter(['src/App.ku.vue']) + const filterKuRoot = createFilter(`${rootPath}/App.ku.vue`) if (filterKuRoot(id)) return await rebuildKuApp(appKuPath) diff --git a/src/root.ts b/src/root.ts index c942340..c33eb27 100644 --- a/src/root.ts +++ b/src/root.ts @@ -19,10 +19,10 @@ export async function registerKuApp(code: string) { } export async function rebuildKuApp(path: string) { - const rootTagNameRE = /\b(?:KuRootView|ku-root-view)\b/ + const rootTagNameRE = /<(KuRootView|ku-root-view)\s*\/>/ const code = await fs.readFile(path, 'utf-8') - const ms = new MagicString(code).replace(rootTagNameRE, 'slot') + const ms = new MagicString(code).replace(rootTagNameRE, '') return ms.toString() }