From 616a4a506dec390bba239cd6290cf0f825050d03 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Wed, 25 Dec 2024 14:52:39 +0800 Subject: [PATCH] build(runtime): _plugin-vue_export-helper js file cant not be access with Github Pages --- runtime/vue3/build.vite.config.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runtime/vue3/build.vite.config.ts b/runtime/vue3/build.vite.config.ts index 54ba84ff1..c436500d0 100644 --- a/runtime/vue3/build.vite.config.ts +++ b/runtime/vue3/build.vite.config.ts @@ -25,6 +25,9 @@ import vueJsx from '@vitejs/plugin-vue-jsx'; // @ts-ignore import externalGlobals from 'rollup-plugin-external-globals'; +const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; +const DRIVE_LETTER_REGEX = /^[a-z]:/i; + export default defineConfig(({ mode }) => { if (['value', 'config', 'event', 'ds:value', 'ds:config', 'ds:event'].includes(mode)) { const capitalToken = mode @@ -80,6 +83,14 @@ export default defineConfig(({ mode }) => { outDir: path.resolve(process.cwd(), `../../playground/public/runtime/vue3/${mode}`), rollupOptions: { external: ['vue', 'vue-demi'], + output: { + // https://github.com/rollup/rollup/blob/master/src/utils/sanitizeFileName.ts + sanitizeFileName(name) { + const match = DRIVE_LETTER_REGEX.exec(name); + const driveLetter = match ? match[0] : ''; + return driveLetter + name.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, ''); + }, + }, }, }, };