vite.config.mjs 2.9 KB

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