vite.config.mjs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { defineConfig, loadEnv } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import vueDevTools from 'vite-plugin-vue-devtools';
  4. // import path from 'path'; // 导入 path 模块
  5. // https://vitejs.dev/config/
  6. export default defineConfig(({ mode }) => {
  7. // const env = loadEnv(mode, process.cwd());
  8. return {
  9. /**
  10. * 项目根目录
  11. * @see https://cn.vite.dev/config/shared-options.html#root
  12. */
  13. root: './src',
  14. /**
  15. * 静态资源目录,相对于 src/index.html 文件
  16. * @see https://cn.vite.dev/config/shared-options.html#publicdir
  17. */
  18. publicDir: '../public',
  19. server: {
  20. port: 5173,
  21. host: '0.0.0.0', // IP配置,支持从IP启动
  22. proxy: {
  23. '/api/': {
  24. target: 'http://smartai.com:8191',
  25. // target: 'http://192.168.20.119:9301',
  26. changeOrigin: true,
  27. secure: false,
  28. ws: true,
  29. cors: true,
  30. rewrite: (path) => path.replace(/^\/proxy_url/, '')
  31. },
  32. '/dify': {
  33. target: 'http://192.168.20.119:28003/',
  34. changeOrigin: true,
  35. secure: false,
  36. ws: true,
  37. rewrite: (path) => path.replace(/^\/dify/, '')
  38. },
  39. '/rgflow': {
  40. target: 'http://192.168.20.119:28002/',
  41. changeOrigin: true,
  42. secure: false,
  43. ws: true,
  44. rewrite: (path) => path.replace(/^\/rgflow/, '')
  45. }
  46. }
  47. },
  48. build: {
  49. /**
  50. * 构建输出目录,相对于 src/index.html 文件
  51. * @see https://cn.vite.dev/config/build-options.html#build-outdir
  52. */
  53. outDir: '../dist',
  54. emptyOutDir: true
  55. },
  56. plugins: [
  57. vue(),
  58. /**
  59. * @see https://devtools.vuejs.org/guide/vite-plugin
  60. */
  61. vueDevTools({
  62. launchEditor: 'code'
  63. })
  64. ]
  65. };
  66. });