vite.config.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { defineConfig } 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({
  6. /**
  7. * 项目根目录
  8. * @see https://cn.vite.dev/config/shared-options.html#root
  9. */
  10. root: './src',
  11. /**
  12. * 静态资源目录,相对于 src/index.html 文件
  13. * @see https://cn.vite.dev/config/shared-options.html#publicdir
  14. */
  15. publicDir: '../public',
  16. server: {
  17. port: 5173,
  18. host: '0.0.0.0', // IP配置,支持从IP启动
  19. proxy: {
  20. '/api': {
  21. target: 'http://smartai.com:8191',
  22. // target: "http://192.168.20.119:9301",
  23. changeOrigin: true,
  24. secure: false,
  25. ws: true,
  26. rewrite: (path) => path.replace(/^\/proxy_url/, '')
  27. }
  28. }
  29. },
  30. build: {
  31. /**
  32. * 构建输出目录,相对于 src/index.html 文件
  33. * @see https://cn.vite.dev/config/build-options.html#build-outdir
  34. */
  35. outDir: '../dist',
  36. emptyOutDir: true
  37. },
  38. plugins: [
  39. vue(),
  40. /**
  41. * @see https://devtools.vuejs.org/guide/vite-plugin
  42. */
  43. vueDevTools({
  44. launchEditor: 'code'
  45. })
  46. ]
  47. });