diff --git a/runtime/react/page/vite.config.ts b/runtime/react/page/vite.config.ts index c88c982d..82ae6569 100644 --- a/runtime/react/page/vite.config.ts +++ b/runtime/react/page/vite.config.ts @@ -2,6 +2,9 @@ import { defineConfig } from 'vite'; import baseConfig from '../vite.config'; +const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; +const DRIVE_LETTER_REGEX = /^[a-z]:/i; + export default defineConfig({ ...baseConfig, @@ -15,5 +18,15 @@ export default defineConfig({ emptyOutDir: false, sourcemap: true, outDir: '../dist/page', + rollupOptions: { + 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, ''); + }, + }, + }, }, }); diff --git a/runtime/react/playground/vite.config.ts b/runtime/react/playground/vite.config.ts index f962701a..4f80c3b1 100644 --- a/runtime/react/playground/vite.config.ts +++ b/runtime/react/playground/vite.config.ts @@ -2,6 +2,9 @@ import { defineConfig } from 'vite'; import baseConfig from '../vite.config'; +const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; +const DRIVE_LETTER_REGEX = /^[a-z]:/i; + export default defineConfig({ ...baseConfig, @@ -15,5 +18,15 @@ export default defineConfig({ emptyOutDir: false, sourcemap: true, outDir: '../dist/playground', + rollupOptions: { + 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, ''); + }, + }, + }, }, }); diff --git a/runtime/vue/page/vite.config.ts b/runtime/vue/page/vite.config.ts index cb716b4f..a294f668 100644 --- a/runtime/vue/page/vite.config.ts +++ b/runtime/vue/page/vite.config.ts @@ -2,6 +2,9 @@ import { defineConfig } from 'vite'; import baseConfig from '../vite.config'; +const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; +const DRIVE_LETTER_REGEX = /^[a-z]:/i; + export default defineConfig({ ...baseConfig, @@ -13,5 +16,15 @@ export default defineConfig({ emptyOutDir: false, sourcemap: true, outDir: '../dist/page', + rollupOptions: { + 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, ''); + }, + }, + }, }, }); diff --git a/runtime/vue/playground/vite.config.ts b/runtime/vue/playground/vite.config.ts index 2d53d389..bacc7906 100644 --- a/runtime/vue/playground/vite.config.ts +++ b/runtime/vue/playground/vite.config.ts @@ -2,6 +2,9 @@ import { defineConfig } from 'vite'; import baseConfig from '../vite.config'; +const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; +const DRIVE_LETTER_REGEX = /^[a-z]:/i; + export default defineConfig({ ...baseConfig, @@ -13,5 +16,15 @@ export default defineConfig({ emptyOutDir: false, sourcemap: true, outDir: '../dist/playground', + rollupOptions: { + 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, ''); + }, + }, + }, }, });