vite.config.mjs 1.3 KB

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