35 lines
631 B
JavaScript
35 lines
631 B
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig(( { command } ) => {
|
|
let branch = process.env.BRANCH || 'main'
|
|
|
|
// 1️⃣ dev 模式:永远 /
|
|
if (command === 'serve') {
|
|
branch = '/'
|
|
}else{
|
|
branch = `/${branch}/`
|
|
}
|
|
|
|
return {
|
|
base: branch,
|
|
build: {
|
|
sourcemap: true
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
vueDevTools(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
},
|
|
},
|
|
}
|
|
})
|