前端:修复多分支部署时静态资源的路径问题 #52
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
VITE_API_BASE_URL = http://localhost:5202/api
|
#VITE_API_BASE_URL = http://localhost:5202/api
|
||||||
VITE_SIGNALR_BASE_URL = http://localhost:5202/chat
|
#VITE_SIGNALR_BASE_URL = http://localhost:5202/chat
|
||||||
#VITE_API_BASE_URL = http://192.168.5.116:7070/api
|
VITE_API_BASE_URL = https://im.test.nxsir.cn/api
|
||||||
#VITE_SIGNALR_BASE_URL = http://192.168.5.116:7070/chat
|
VITE_SIGNALR_BASE_URL = https://im.test.nxsir.cn/chat
|
||||||
@@ -4,9 +4,20 @@ import { defineConfig } from 'vite'
|
|||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||||
|
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig(( { command } ) => {
|
||||||
base: './',
|
let branch = process.env.BRANCH || 'main'
|
||||||
|
|
||||||
|
// 1️⃣ dev 模式:永远 /
|
||||||
|
if (command === 'serve') {
|
||||||
|
branch = '/'
|
||||||
|
}else{
|
||||||
|
branch = `/${branch}/`
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
base: branch,
|
||||||
build: {
|
build: {
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
},
|
},
|
||||||
@@ -19,4 +30,5 @@ export default defineConfig({
|
|||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user