vite.config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import Pages from 'vite-plugin-pages'
  4. import Layouts from 'vite-plugin-vue-layouts'
  5. import path from 'path'
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. plugins: [
  9. vue(),
  10. Pages({
  11. dirs: [
  12. {
  13. dir: 'src/page',
  14. baseRoute: ''
  15. },
  16. {
  17. dir: 'src/views',
  18. baseRoute: ''
  19. }
  20. ],
  21. exclude: [
  22. '**/components/*.vue',
  23. '**/component/*.vue',
  24. '**/component/**/*'
  25. ]
  26. }),
  27. Layouts({
  28. layoutsDirs: 'src/layout',
  29. defaultLayout: 'index'
  30. })
  31. ],
  32. resolve: {
  33. alias: {
  34. '@': path.resolve(path.resolve(), 'src')
  35. }
  36. },
  37. minify: 'terser',
  38. build: {
  39. chunkSizeWarningLimit: 1500,
  40. rollupOptions: {
  41. output: {
  42. manualChunks(id) {
  43. if (id.includes('node_modules')) {
  44. return id
  45. .toString()
  46. .split('node_modules/')[1]
  47. .split('/')[0]
  48. .toString()
  49. }
  50. }
  51. }
  52. }
  53. },
  54. server: {
  55. open: true,
  56. proxy: {
  57. '/api': {
  58. // 正式环境地址
  59. // target: 'https://dev.wutongresearch.club/api',
  60. target: 'https://prod.wutongshucloud.com/api',
  61. // target: 'http://192.168.31.181:8110',
  62. changeOrigin: true,
  63. rewrite: path => path.replace(/^\/api/, '')
  64. }
  65. }
  66. }
  67. })