vite.config.mjs 1.8 KB

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