1
0

vite.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig } from "vite";
  3. import { babel } from '@rollup/plugin-babel';
  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. ],
  12. resolve: {
  13. alias: {
  14. "@": fileURLToPath(new URL("./src", import.meta.url)),
  15. },
  16. },
  17. server: {
  18. // 是否开启 https
  19. https: false,
  20. // 端口号
  21. // port: 3000,
  22. // 监听所有地址
  23. host: "0.0.0.0",
  24. // 服务启动时是否自动打开浏览器
  25. open: true,
  26. // 允许跨域
  27. cors: true,
  28. // 自定义代理规则
  29. proxy: {
  30. "/camera-api": {
  31. target: "https://ycjk.cq119.gov.cn",
  32. changeOrigin: true,
  33. rewrite: (path) => path.replace(/^\/camera-api/, ""),
  34. }
  35. },
  36. },
  37. build: {
  38. // 构建后是否生成 source map 文件
  39. sourcemap: false,
  40. // chunk 大小警告的限制(以 kbs 为单位)
  41. chunkSizeWarningLimit: 2000,
  42. // 启用/禁用 gzip 压缩大小报告
  43. reportCompressedSize: false,
  44. cssTarget: 'chrome70',
  45. target: 'es2015',
  46. rollupOptions: {
  47. plugins: [
  48. // https://www.npmjs.com/package/@rollup/plugin-babel
  49. babel({
  50. babelHelpers: 'bundled',
  51. presets: [
  52. [
  53. '@babel/preset-env',
  54. {
  55. useBuiltIns: 'entry', // 注意这里只能使用 entry
  56. corejs: '3',
  57. targets: 'last 2 versions and not dead, > 0.2%, Firefox ESR',
  58. },
  59. ],
  60. ],
  61. plugins: [],
  62. compact: false,
  63. })
  64. ]
  65. }
  66. },
  67. });