vite.config.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import vueJsx from '@vitejs/plugin-vue-jsx'
  5. const Timestamp = new Date().getTime();
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. // base: '/highLevelIntellectual/',
  9. build: {
  10. chunkSizeWarningLimit: 1500,
  11. rollupOptions: {
  12. output: {
  13. // 最小化拆分包
  14. manualChunks(id) {
  15. if (id.includes('node_modules')) {
  16. return id.toString().split('node_modules/')[1].split('/')[0].toString()
  17. }
  18. },
  19. // 用于从入口点创建的块的打包输出格式[name]表示文件名,[hash]表示该文件内容hash值
  20. entryFileNames: `assets/js/[name].[hash].${Timestamp}.js`, // 用于命名代码拆分时创建的共享块的输出命名
  21. chunkFileNames: `assets/js/[name].[hash].${Timestamp}.js`, // 用于输出静态资源的命名,[ext]表示文件扩展名
  22. assetFileNames: `assets/[ext]/[name].[hash].${Timestamp}.[ext]`
  23. }
  24. }
  25. },
  26. base: '/fireBrigade/',
  27. css: {
  28. preprocessorOptions: {
  29. scss: {
  30. api: "modern-compiler" // or 'modern'
  31. }
  32. }
  33. },
  34. plugins: [
  35. vue(),
  36. vueJsx(),
  37. ],
  38. server: { // ← ← ← ← ← ←
  39. host: '0.0.0.0', // ← 新增内容 ←
  40. // port: 8991,
  41. },
  42. resolve: {
  43. alias: {
  44. '@': fileURLToPath(new URL('./src', import.meta.url))
  45. }
  46. }
  47. })