From 96c52d9e0c4beee55553845ed0127932591223bc Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Fri, 17 Nov 2023 16:21:49 +0800 Subject: [PATCH] fix loading static resource bug --- web/vite.config.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/web/vite.config.ts b/web/vite.config.ts index 917972e..94c2343 100755 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -3,6 +3,9 @@ import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$&*+,:;<=>?[\]^`{|}\u007F]/g; +const DRIVE_LETTER_REGEX = /^[a-z]:/i; + // https://vitejs.dev/config/ export default defineConfig({ base: "/plugin/topology", @@ -18,7 +21,7 @@ export default defineConfig({ proxy:{ "/plugin/topology/api": { // target: 'http://192.168.241.129:9991', - target: 'http://10.44.55.72:9991', + target: 'http://10.41.121.1:9991', changeOrigin:true, // rewrite: (path)=> path.replace("/^\/api/", ""), }, @@ -28,5 +31,22 @@ export default defineConfig({ // rewrite: (path)=> path.replace("/^\/api/", ""), } } - } + }, + build: { + 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] : ""; + // A `:` is only allowed as part of a windows drive letter (ex: C:\foo) + // Otherwise, avoid them because they can refer to NTFS alternate data streams. + return ( + driveLetter + + name.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, "") + ); + }, + }, + }, + }, }) -- Gitee