Skip to content

Commit f85ee9c

Browse files
committed
Fix GitHub Pages.
1 parent 9f35f4b commit f85ee9c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

vite.config.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { fileURLToPath, URL } from 'node:url'
33
import { defineConfig } from 'vite'
44
import vue from '@vitejs/plugin-vue'
55

6+
7+
const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g;
8+
const DRIVE_LETTER_REGEX = /^[a-z]:/i;
9+
610
// https://vitejs.dev/config/
711
export default defineConfig({
812
plugins: [
@@ -12,5 +16,21 @@ export default defineConfig({
1216
alias: {
1317
'@': fileURLToPath(new URL('./src', import.meta.url))
1418
}
15-
}
19+
},
20+
// https://fyhhub.github.io/informal/%E8%B8%A9%E5%9D%91%E8%AE%B0%E5%BD%95/Vite%20%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%20_plugin-vue_export-helper%20%E6%96%87%E4%BB%B6%20404%20%E9%97%AE%E9%A2%98.html
21+
build: {
22+
rollupOptions: {
23+
output: {
24+
// https://github.com/rollup/rollup/blob/master/src/utils/sanitizeFileName.ts
25+
sanitizeFileName(fileName) {
26+
const match = DRIVE_LETTER_REGEX.exec(fileName);
27+
const driveLetter = match ? match[0] : "";
28+
return (
29+
driveLetter +
30+
fileName.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, "")
31+
);
32+
},
33+
},
34+
},
35+
},
1636
})

0 commit comments

Comments
 (0)