市场夺宝奇兵
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.

48 lines
1.2 KiB

  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig, loadEnv } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import vueDevTools from 'vite-plugin-vue-devtools'
  5. // https://vite.dev/config/
  6. export default defineConfig(({ mode, command }) => {
  7. // 正确加载环境变量 - 只加载 VITE_ 前缀的变量:cite[9]
  8. const env = loadEnv(mode, process.cwd(), 'VITE_')
  9. const outDirMap = {
  10. development: 'dist-test',
  11. production: 'dist-prod'
  12. }
  13. return {
  14. // 确保基础路径正确
  15. base: './',
  16. plugins: [
  17. vue(),
  18. vueDevTools(),
  19. ],
  20. resolve: {
  21. alias: {
  22. '@': fileURLToPath(new URL('./src', import.meta.url))
  23. },
  24. },
  25. build: {
  26. outDir: outDirMap[mode] || 'dist',
  27. rollupOptions: {
  28. input: {
  29. main: './index.html',
  30. download: './hcdbqb-download.html',
  31. guide: './hcdbqb-guide.html',
  32. management: './hcdbqb-management.html'
  33. },
  34. output: {
  35. entryFileNames: '[name].js', // 入口文件命名
  36. chunkFileNames: '[name].js', // 代码分割块命名
  37. assetFileNames: '[name].[ext]' // 静态资源命名
  38. }
  39. }
  40. },
  41. server: {
  42. port: 5173,
  43. open: true
  44. },
  45. }
  46. })