You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
import { fileURLToPath, URL } from 'node:url'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig(({ mode, command }) => {
|
|
// 正确加载环境变量 - 只加载 VITE_ 前缀的变量:cite[9]
|
|
const env = loadEnv(mode, process.cwd(), 'VITE_')
|
|
|
|
const outDirMap = {
|
|
development: 'dist-test',
|
|
production: 'dist-prod'
|
|
}
|
|
|
|
return {
|
|
// 确保基础路径正确
|
|
base: './',
|
|
plugins: [
|
|
vue(),
|
|
vueDevTools(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
},
|
|
},
|
|
build: {
|
|
outDir: outDirMap[mode] || 'dist',
|
|
rollupOptions: {
|
|
input: {
|
|
main: './index.html',
|
|
download: './hcdbqb-download.html',
|
|
guide: './hcdbqb-guide.html',
|
|
management: './hcdbqb-management.html'
|
|
},
|
|
output: {
|
|
entryFileNames: '[name].js', // 入口文件命名
|
|
chunkFileNames: '[name].js', // 代码分割块命名
|
|
assetFileNames: '[name].[ext]' // 静态资源命名
|
|
}
|
|
}
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
open: true
|
|
},
|
|
}
|
|
})
|