vite.config.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. '@views': resolve('src/views')
  39. }
  40. },
  41. //代理
  42. server: {
  43. proxy: {
  44. '/api': {
  45. // target: 'http://192.168.0.131:8188/TransServlet',//配置文件获取地址
  46. target: 'https://www.adicn.com/airopt',
  47. secure: false, //接受使用https
  48. changeOrigin: true, //允许跨域
  49. ws: false, //使用websocket
  50. rewrite: (path) => path.replace(/^\/api/, '')
  51. },
  52. '/airopt': {
  53. // target: 'http://192.168.0.131:8188/TransServlet',//配置文件获取地址
  54. target: 'https://www.adicn.com/airopt',
  55. secure: false, //接受使用https
  56. changeOrigin: true, //允许跨域
  57. ws: false, //使用websocket
  58. rewrite: (path) => path.replace(/^\/airopt/, '')
  59. },
  60. '/file': {
  61. // target: 'http://192.168.0.15:8081/', // 后端接口地址
  62. target: 'http://192.168.0.43:2201/',
  63. secure: false, //接受使用https
  64. changeOrigin: true, //允许跨域
  65. ws: false, //使用websocket
  66. pathRewrite: { // 路径重写
  67. '^/file': ''
  68. }
  69. }, '/websokct': {
  70. target: 'http://192.168.0.104:8188',
  71. // target: 'http://192.168.0.43:8081/',
  72. // target: 'https://www.gzchain.org.cn/managersvc/', //后端接口地址
  73. secure: false, //接受使用https
  74. },
  75. }
  76. },
  77. renderer: {
  78. css: {
  79. preprocessorOptions: {
  80. scss: {
  81. silenceDeprecations: ['legacy-js-api']
  82. }
  83. }
  84. }
  85. }
  86. }
  87. })