vite.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {defineConfig} from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import * as path from 'path'
  4. // 自动导入vue中hook reactive ref等
  5. import AutoImport from "unplugin-auto-import/vite"
  6. //自动导入ui-组件 比如说ant-design-vue element-plus等
  7. import Components from 'unplugin-vue-components/vite';
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. plugins: [
  11. vue(),
  12. AutoImport({
  13. //安装两行后你会发现在组件中不用再导入ref,reactive等
  14. imports: ['vue', 'vue-router'],
  15. //存放的位置
  16. dts: "src/auto-import.d.ts",
  17. }),
  18. Components({
  19. // 引入组件的,包括自定义组件
  20. // 存放的位置
  21. dts: "src/components.d.ts",
  22. }),
  23. ],
  24. resolve: {
  25. alias: {
  26. '@': path.resolve(__dirname, './src'),
  27. },
  28. },
  29. // 解决跨域问题
  30. server: {
  31. host: '0.0.0.0',
  32. // port: 4000,
  33. proxy: {
  34. '/api': {
  35. target: 'http://192.168.110.218:8220',
  36. // secure: false, // 请求是否为https
  37. changeOrigin: true,
  38. rewrite: (path) => path.replace(/^\/api/, '') //api替换为'',
  39. },
  40. },
  41. },
  42. // resolve: {
  43. // alias: {
  44. // '@': path.resolve(__dirname, 'src'),
  45. // },
  46. // },
  47. })