vite.config.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { defineConfig, loadEnv } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import monacoEditorPlugin from 'vite-plugin-monaco-editor';
  4. import removeConsole from 'vite-plugin-remove-console';
  5. import compression from 'vite-plugin-compression';
  6. //1、 导入 path 模块,帮助我们解析路径
  7. import { resolve } from 'path'
  8. //2-1 自动导入vue中hook reactive ref等
  9. import AutoImport from 'unplugin-auto-import/vite'
  10. //2-2 自动导入ui-组件 比如说ant-design-vue element-plus等
  11. import Components from 'unplugin-vue-components/vite'
  12. //3、vue3语法糖
  13. import VueSetupExtend from 'vite-plugin-vue-setup-extend'
  14. // https://vitejs.dev/config/
  15. export default defineConfig(({ mode }) => {
  16. const config = loadEnv(mode, './');
  17. if (mode === 'development') console.debug('Loaded env:', config);
  18. return {
  19. base: "./",
  20. plugins: [
  21. vue(),
  22. removeConsole(),
  23. compression(),
  24. monacoEditorPlugin({}),
  25. AutoImport({
  26. imports: ['vue', 'vue-router'],
  27. dts: "src/auto-import.d.ts",
  28. }),
  29. Components({
  30. dts: "src/components.d.ts",
  31. }),
  32. VueSetupExtend(),
  33. ],
  34. resolve: {
  35. alias: {
  36. '@': resolve('src'),
  37. '@views': resolve('src/views')
  38. }
  39. },
  40. server: {
  41. proxy: {
  42. '/api': {
  43. target: 'https://www.adicn.com/eps',
  44. secure: false,
  45. changeOrigin: true,
  46. rewrite: (path) => path.replace(/^\/api/, '')
  47. },
  48. '/eps': {
  49. target: 'https://www.adicn.com/eps',
  50. secure: false,
  51. changeOrigin: true,
  52. rewrite: (path) => path.replace(/^\/eps/, '')
  53. },
  54. '/file': {
  55. target: 'http://192.168.0.43:2201/',
  56. secure: false,
  57. changeOrigin: true,
  58. rewrite: path => path.replace(/^\/file/, '')
  59. },
  60. '/websocket': { // 原为 websockt,修正拼写
  61. target: 'http://192.168.0.104:8188',
  62. secure: false,
  63. changeOrigin: true
  64. },
  65. }
  66. },
  67. css: {
  68. preprocessorOptions: {
  69. scss: {
  70. // optional: global SCSS variables/mixins
  71. // additionalData: `@import "@/styles/variables.scss";`
  72. }
  73. }
  74. }
  75. };
  76. });