vite.config.mjs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. '/api/': {
  22. // target: 'http://192.168.20.119:9601',
  23. target: 'http://192.168.20.72:9601',
  24. // target: 'https://192.168.20.119:26100',
  25. changeOrigin: true,
  26. secure: false,
  27. ws: true,
  28. cors: true,
  29. rewrite: (path) => path.replace(/^\/proxy_url/, '')
  30. }
  31. }
  32. },
  33. build: {
  34. /**
  35. * 构建输出目录,相对于 src/index.html 文件
  36. * @see https://cn.vite.dev/config/build-options.html#build-outdir
  37. */
  38. outDir: '../dist',
  39. emptyOutDir: true
  40. },
  41. resolve: {
  42. alias: {
  43. '@': path.resolve(__dirname, './src') // 配置@指向src目录
  44. }
  45. },
  46. plugins: [
  47. vue()
  48. /**
  49. * @see https://devtools.vuejs.org/guide/vite-plugin
  50. */
  51. // vueDevTools({
  52. // launchEditor: 'code'
  53. // })
  54. ]
  55. });