vite.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig } from "vite";
  3. import legacy from "@vitejs/plugin-legacy";
  4. import vue2 from "@vitejs/plugin-vue2";
  5. import vue2Jsx from "@vitejs/plugin-vue2-jsx";
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. plugins: [
  9. vue2(),
  10. vue2Jsx(),
  11. legacy({
  12. targets: ["ie >= 11"],
  13. additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
  14. }),
  15. ],
  16. resolve: {
  17. alias: {
  18. "@": fileURLToPath(new URL("./src", import.meta.url)),
  19. },
  20. },
  21. server: {
  22. // 是否开启 https
  23. https: false,
  24. // 端口号
  25. // port: 3000,
  26. // 监听所有地址
  27. host: "0.0.0.0",
  28. // 服务启动时是否自动打开浏览器
  29. open: true,
  30. // 允许跨域
  31. cors: true,
  32. // 自定义代理规则
  33. proxy: {},
  34. },
  35. build: {
  36. // 设置最终构建的浏览器兼容目标
  37. target: "es2015",
  38. // 构建后是否生成 source map 文件
  39. sourcemap: false,
  40. // chunk 大小警告的限制(以 kbs 为单位)
  41. chunkSizeWarningLimit: 2000,
  42. // 启用/禁用 gzip 压缩大小报告
  43. reportCompressedSize: false,
  44. },
  45. });