vite.config.mjs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. base: './',
  17. server: {
  18. port: 5173,
  19. host: '0.0.0.0', // IP配置,支持从IP启动
  20. proxy: {
  21. '/iaserverapi': {
  22. // target: 'http://192.168.141.78:5678',
  23. // target: 'http://172.20.10.3:5678',
  24. // target: 'http://192.168.0.100:5678',
  25. target: 'http://47.117.92.63:5678/',
  26. // target: 'http://ty.bai.sc.sgcc.com.cn',
  27. // target: 'http://25.214.216.111:9000',
  28. changeOrigin: true,
  29. secure: false,
  30. ws: true,
  31. // rewrite: (path) => path.replace(/^\/iaserverapi/, '')
  32. }
  33. }
  34. },
  35. build: {
  36. /**
  37. * 构建输出目录,相对于 src/index.html 文件
  38. * @see https://cn.vite.dev/config/build-options.html#build-outdir
  39. */
  40. outDir: '../dist',
  41. assetsDir: 'static',
  42. assetsInclude: ['**/*.exe'], // 显式包含.exe文件类型
  43. emptyOutDir: true,
  44. target: ['es2022', 'edge85'],
  45. terserOptions: {
  46. compress: {
  47. drop_console: true, // 移除 console 语句
  48. drop_debugger: true // 移除 debugger 语句
  49. }
  50. }
  51. },
  52. plugins: [
  53. vue()
  54. /**
  55. * @see https://devtools.vuejs.org/guide/vite-plugin
  56. */
  57. // vueDevTools({
  58. // launchEditor: 'code'
  59. // })
  60. ],
  61. });