vite.config.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { defineConfig,loadEnv } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. //1、 导入 path 模块,帮助我们解析路径
  4. import { resolve } from 'path'
  5. //2-1 自动导入vue中hook reactive ref等
  6. import AutoImport from 'unplugin-auto-import/vite'
  7. //2-2 自动导入ui-组件 比如说ant-design-vue element-plus等
  8. import Components from 'unplugin-vue-components/vite'
  9. //3、vue3语法糖
  10. import VueSetupExtend from 'vite-plugin-vue-setup-extend'
  11. // https://vitejs.dev/config/
  12. export default defineConfig({
  13. plugins: [
  14. vue(),
  15. AutoImport({
  16. //安装两行后你会发现在组件中不用再导入ref,reactive等
  17. imports: ['vue', 'vue-router'],
  18. //存放的位置
  19. dts: "src/auto-import.d.ts",
  20. }),
  21. Components({
  22. // 引入组件的,包括自定义组件,存放的位置
  23. dts: "src/components.d.ts",
  24. }),
  25. VueSetupExtend(),
  26. ],
  27. //1、 ↓解析配置
  28. resolve: {
  29. // ↓路径别名
  30. alias: {
  31. '@': resolve('src')
  32. }
  33. },
  34. //代理
  35. server: {
  36. proxy: {
  37. '/api': {
  38. // target: 'http://localhost:8081/', // 后端接口地址
  39. target: 'http://192.168.0.131:8187/TransServlet',
  40. //target: 'http://192.168.0.131:8087/TransServlet',
  41. // target: 'https://www.gzchain.org.cn/managersvc/', //后端接口地址
  42. secure: false, //接受使用https
  43. changeOrigin: true, //允许跨域
  44. ws: false, //使用websocket
  45. rewrite: (path)=>path.replace(/^\/api/,'')
  46. },
  47. '/file': {
  48. // target: 'http://192.168.0.15:8081/', // 后端接口地址
  49. target: 'http://192.168.0.43:2201/',
  50. secure: false, //接受使用https
  51. changeOrigin: true, //允许跨域
  52. ws: false, //使用websocket
  53. pathRewrite: { // 路径重写
  54. '^/file': ''
  55. }
  56. }, '/websokct':{
  57. target: 'http://192.168.0.131:8081/',
  58. // target: 'http://192.168.0.43:8081/',
  59. // target: 'https://www.gzchain.org.cn/managersvc/', //后端接口地址
  60. secure: false, //接受使用https
  61. },
  62. }
  63. }
  64. })