vite.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. import cesium from 'vite-plugin-cesium';
  7. // https://vitejs.dev/config/
  8. export default defineConfig({
  9. plugins: [
  10. vue2(),
  11. vue2Jsx(),
  12. cesium(),
  13. legacy({
  14. targets: ['IE 11'],
  15. additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
  16. }),
  17. ],
  18. resolve: {
  19. alias: {
  20. "@": fileURLToPath(new URL("./src", import.meta.url)),
  21. },
  22. },
  23. server: {
  24. // 是否开启 https
  25. https: false,
  26. // 端口号
  27. // port: 3000,
  28. // 监听所有地址
  29. host: "0.0.0.0",
  30. // 服务启动时是否自动打开浏览器
  31. open: true,
  32. // 允许跨域
  33. cors: true,
  34. // 自定义代理规则
  35. proxy: {
  36. "/camera-api": {
  37. target: "https://ycjk.cq119.gov.cn",
  38. changeOrigin: true,
  39. rewrite: (path) => path.replace(/^\/camera-api/, ""),
  40. }
  41. },
  42. },
  43. build: {
  44. // 构建后是否生成 source map 文件
  45. sourcemap: false,
  46. // chunk 大小警告的限制(以 kbs 为单位)
  47. chunkSizeWarningLimit: 2000,
  48. // 启用/禁用 gzip 压缩大小报告
  49. reportCompressedSize: false,
  50. },
  51. });