vite.config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import VueDevTools from 'vite-plugin-vue-devtools'
  5. import VueSetupExtend from 'vite-plugin-vue-setup-extend'
  6. import autoImport from 'unplugin-auto-import/vite'
  7. import AutoImport from 'unplugin-auto-import/vite'
  8. import Components from 'unplugin-vue-components/vite'
  9. import { VantResolver } from '@vant/auto-import-resolver'
  10. const createAutoImport = () => {
  11. return autoImport({
  12. imports: ['vue', 'vue-router', 'pinia'],
  13. dts: false
  14. })
  15. }
  16. // https://vitejs.dev/config/
  17. export default defineConfig({
  18. plugins: [
  19. vue(),
  20. VueDevTools(),
  21. VueSetupExtend(),
  22. createAutoImport(),
  23. AutoImport({
  24. resolvers: [VantResolver()]
  25. }),
  26. Components({
  27. resolvers: [VantResolver()]
  28. })
  29. ],
  30. resolve: {
  31. alias: {
  32. '@': fileURLToPath(new URL('./src', import.meta.url))
  33. }
  34. },
  35. server: {
  36. host: true,
  37. proxy: {
  38. '/dev-api': {
  39. target: 'http://172.16.10.61:8080',
  40. // target: 'https://vue.ruoyi.vip/prod-api',
  41. changeOrigin: true,
  42. rewrite: (p) => p.replace(/^\/dev-api/, '')
  43. }
  44. }
  45. },
  46. //配置sass
  47. css: {
  48. preprocessorOptions: {
  49. scss: {
  50. additionalData:
  51. '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";'
  52. }
  53. }
  54. }
  55. })