vite.config.mjs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. // import vueDevTools from 'vite-plugin-vue-devtools';
  4. import { visualizer } from 'rollup-plugin-visualizer';
  5. import viteCompression from 'vite-plugin-compression';
  6. // import viteImagemin from 'vite-plugin-imagemin';
  7. /**
  8. * 按需加载
  9. * @see https://arco.design/vue/docs/start#%E6%8C%89%E9%9C%80%E5%8A%A0%E8%BD%BD%EF%BC%88%E6%A8%A1%E6%9D%BF%EF%BC%89
  10. */
  11. import AutoImport from 'unplugin-auto-import/vite';
  12. import Components from 'unplugin-vue-components/vite';
  13. import { ArcoResolver } from 'unplugin-vue-components/resolvers';
  14. import { config_compression, config_imagemin } from './scripts/vite-conf';
  15. // https://vitejs.dev/config/
  16. export default defineConfig(({ mode }) => {
  17. return {
  18. /**
  19. * 项目根目录
  20. * @see https://cn.vite.dev/config/shared-options.html#root
  21. */
  22. root: './src',
  23. /**
  24. * 静态资源目录,相对于 src/index.html 文件
  25. * @see https://cn.vite.dev/config/shared-options.html#publicdir
  26. */
  27. publicDir: '../public',
  28. server: {
  29. port: 5173,
  30. host: '0.0.0.0', // IP配置,支持从IP启动
  31. proxy: {
  32. '/api/': {
  33. target: 'http://smartai.com:8401',
  34. // target: 'http://192.168.20.119:9303',
  35. changeOrigin: true,
  36. secure: false,
  37. ws: true,
  38. cors: true,
  39. rewrite: (path) => path.replace(/^\/proxy_url/, '')
  40. },
  41. '/console/': {
  42. target: 'http://smartai.com:8163',
  43. // target: 'http://192.168.20.119:9303',
  44. changeOrigin: true,
  45. secure: false,
  46. ws: true,
  47. cors: true,
  48. rewrite: (path) => path.replace(/^\/proxy_url/, '')
  49. },
  50. '/dify': {
  51. target: 'http://192.168.20.119:28003/',
  52. changeOrigin: true,
  53. secure: false,
  54. ws: true,
  55. rewrite: (path) => path.replace(/^\/dify/, '')
  56. },
  57. '/rgflow': {
  58. target: 'http://192.168.20.119:28002/',
  59. // target: 'http://smartai.com:8294/',
  60. changeOrigin: true,
  61. secure: false,
  62. ws: true,
  63. rewrite: (path) => path.replace(/^\/rgflow/, '')
  64. }
  65. }
  66. },
  67. build: {
  68. /**
  69. * 构建输出目录,相对于 src/index.html 文件
  70. * @see https://cn.vite.dev/config/build-options.html#build-outdir
  71. */
  72. outDir: '../dist',
  73. emptyOutDir: true,
  74. rollupOptions: {
  75. output: {
  76. manualChunks: {
  77. 'vue-vendor': ['vue', 'vue-router', 'pinia']
  78. }
  79. }
  80. },
  81. terserOptions: {
  82. output: {
  83. // 去掉注释内容
  84. comments: true
  85. }
  86. }
  87. },
  88. plugins: [
  89. vue(),
  90. // /**
  91. // * @see https://devtools.vuejs.org/guide/vite-plugin
  92. // */
  93. // vueDevTools({
  94. // launchEditor: 'code'
  95. // }),
  96. visualizer({ open: false }),
  97. viteCompression(config_compression),
  98. // viteImagemin(config_imagemin),
  99. /**
  100. * 按需加载
  101. * @see https://arco.design/vue/docs/start#%E6%8C%89%E9%9C%80%E5%8A%A0%E8%BD%BD%EF%BC%88%E6%A8%A1%E6%9D%BF%EF%BC%89
  102. */
  103. AutoImport({
  104. resolvers: [ArcoResolver()]
  105. }),
  106. Components({
  107. resolvers: [
  108. ArcoResolver({
  109. sideEffect: true
  110. })
  111. ]
  112. })
  113. ]
  114. };
  115. });