vite.config.mjs 3.1 KB

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