import { fileURLToPath, URL } from "node:url"; import { defineConfig } from "vite"; import { babel } from '@rollup/plugin-babel'; import vue2 from "@vitejs/plugin-vue2"; import vue2Jsx from "@vitejs/plugin-vue2-jsx"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue2(), vue2Jsx() ], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, server: { // 是否开启 https https: false, // 端口号 // port: 3000, // 监听所有地址 host: "0.0.0.0", // 服务启动时是否自动打开浏览器 open: true, // 允许跨域 cors: true, // 自定义代理规则 proxy: { "/camera-api": { target: "https://ycjk.cq119.gov.cn", changeOrigin: true, rewrite: (path) => path.replace(/^\/camera-api/, ""), } }, }, build: { // 构建后是否生成 source map 文件 sourcemap: false, // chunk 大小警告的限制(以 kbs 为单位) chunkSizeWarningLimit: 2000, // 启用/禁用 gzip 压缩大小报告 reportCompressedSize: false, cssTarget: 'chrome70', target: 'es2015', rollupOptions: { plugins: [ // https://www.npmjs.com/package/@rollup/plugin-babel babel({ babelHelpers: 'bundled', presets: [ [ '@babel/preset-env', { useBuiltIns: 'entry', // 注意这里只能使用 entry corejs: '3', targets: 'last 2 versions and not dead, > 0.2%, Firefox ESR', }, ], ], plugins: [], compact: false, }) ] } }, });