vite.config.js 913 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. {
  12. dirs: [
  13. { dir: 'src/page', baseRoute: '' },
  14. { dir: 'src/views', baseRoute: '' }
  15. ],
  16. exclude: ['**/components/*.vue'] // 排除组件
  17. }
  18. ),
  19. Layouts({
  20. layoutsDirs: 'src/layout',
  21. defaultLayout: 'index'
  22. })
  23. ],
  24. resolve: {
  25. alias: {
  26. '@': path.resolve(path.resolve(), 'src')
  27. }
  28. },
  29. minify: 'terser',
  30. server: {
  31. open: true,
  32. proxy: {
  33. '/api': {
  34. // 正式环境地址
  35. target: 'https://dev.wutongresearch.club/api',
  36. changeOrigin: true,
  37. rewrite: (path) => path.replace(/^\/api/, '')
  38. }
  39. }
  40. }
  41. })