vite.config.mjs 3.0 KB

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