vite.config.js 840 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path'
  4. // 统一使用 path.resolve
  5. const resolve = (dir) => path.resolve(__dirname, dir)
  6. export default defineConfig({
  7. base: process.env.ELECTRON ? './' : '/',
  8. plugins: [vue()],
  9. server: {
  10. host: '0.0.0.0', // 允许通过IP访问
  11. port: 3000, // 设置端口号
  12. open: true // 自动打开浏览器
  13. },
  14. resolve: {
  15. alias: {
  16. '@': resolve('src'),
  17. '@views': resolve('src/views'),
  18. '@components': resolve('src/components'),
  19. '@assets': resolve('src/assets'),
  20. }
  21. },
  22. build: {
  23. chunkSizeWarningLimit: 1500,
  24. rollupOptions: {
  25. output: {
  26. manualChunks(id) {
  27. if (id.includes('node_modules')) {
  28. return 'vendor';
  29. }
  30. }
  31. }
  32. }
  33. }
  34. })