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