vite.config.ts 3.1 KB

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