vite.config.mjs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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: 5173,
  19. host: '0.0.0.0', // IP配置,支持从IP启动
  20. proxy: {
  21. '/api/': {
  22. target: 'http://192.168.20.119:9301',
  23. // target: "http://192.168.20.119:9301",
  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. plugins: [
  40. vue(),
  41. /**
  42. * @see https://devtools.vuejs.org/guide/vite-plugin
  43. */
  44. vueDevTools({
  45. launchEditor: 'code'
  46. })
  47. ]
  48. });