vite.config.mjs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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:9301',
  35. // target: 'http://192.168.20.116:28004',
  36. // target: 'http://smartai.com:8164',
  37. changeOrigin: true,
  38. secure: false,
  39. ws: true,
  40. cors: true,
  41. rewrite: (path) => path.replace(/^\/proxy_url/, '')
  42. },
  43. '/dify': {
  44. // target: 'http://192.168.20.119:28003/',
  45. target: 'http://47.96.40.148:8163',
  46. changeOrigin: true,
  47. secure: false,
  48. ws: true,
  49. rewrite: (path) => path.replace(/^\/dify/, '')
  50. },
  51. '/rgflow': {
  52. // target: 'http://192.168.20.119:11080',
  53. // target: 'http://smartai.com:8294/', //119 rag
  54. // target: 'http://192.168.20.116:28002/',
  55. target: 'http://47.96.40.148:8162/',
  56. changeOrigin: true,
  57. secure: false,
  58. ws: true,
  59. rewrite: (path) => path.replace(/^\/rgflow/, '')
  60. }
  61. }
  62. },
  63. build: {
  64. /**
  65. * 构建输出目录,相对于 src/index.html 文件
  66. * @see https://cn.vite.dev/config/build-options.html#build-outdir
  67. */
  68. outDir: '../dist',
  69. emptyOutDir: true,
  70. rollupOptions: {
  71. output: {
  72. manualChunks: {
  73. 'vue-vendor': ['vue', 'vue-router', 'pinia']
  74. }
  75. }
  76. },
  77. terserOptions: {
  78. output: {
  79. // 去掉注释内容
  80. comments: true
  81. }
  82. }
  83. },
  84. plugins: [
  85. vue(),
  86. // /**
  87. // * @see https://devtools.vuejs.org/guide/vite-plugin
  88. // */
  89. // vueDevTools({
  90. // launchEditor: 'code'
  91. // }),
  92. visualizer({ open: false }),
  93. viteCompression(config_compression),
  94. viteImagemin(config_imagemin),
  95. /**
  96. * 按需加载
  97. * @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
  98. */
  99. AutoImport({
  100. resolvers: [ArcoResolver()]
  101. }),
  102. Components({
  103. resolvers: [
  104. ArcoResolver({
  105. sideEffect: true
  106. })
  107. ]
  108. })
  109. ]
  110. };
  111. });