vite.config.mjs 3.2 KB

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