vite.config.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import AutoImport from 'unplugin-auto-import/vite'
  4. import Components from 'unplugin-vue-components/vite'
  5. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  6. import Pages from 'vite-plugin-pages'
  7. import path from 'path'
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. plugins: [
  11. vue(),
  12. Pages({
  13. dirs: [
  14. { dir: 'src/page', baseRoute: '' },
  15. { dir: 'src/views', baseRoute: '' }
  16. ],
  17. exclude: ['**/component/*.vue'] // 排除组件
  18. }),
  19. AutoImport({
  20. resolvers: [ElementPlusResolver()]
  21. }),
  22. Components({
  23. dts: true,
  24. resolvers: [ElementPlusResolver()]
  25. })
  26. ],
  27. resolve: {
  28. alias: {
  29. '@': path.resolve(path.resolve(), 'src')
  30. }
  31. },
  32. minify: 'terser',
  33. server: {
  34. open: true,
  35. proxy: {
  36. '/api': {
  37. // 正式环境地址
  38. // target: 'https://dev.wutongresearch.club/api',
  39. target: 'https://prod.wutongshucloud.com/api',
  40. // target: 'http://192.168.31.181:8110',
  41. changeOrigin: true,
  42. rewrite: path => path.replace(/^\/api/, '')
  43. }
  44. }
  45. }
  46. })