import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import vueJsx from "@vitejs/plugin-vue-jsx"; import legacy from "@vitejs/plugin-legacy"; import { resolve } from "path"; import postCssPxToRem from "postcss-pxtorem"; import { visualizer } from "rollup-plugin-visualizer"; import viteCompression from "vite-plugin-compression"; // https://vitejs.dev/config/ export default defineConfig({ base: "./", resolve: {}, // assetsInclude: ['**/*.html'], plugins: [ // mkcert(), // 本地https legacy({ targets: ["Chrome 63"], additionalLegacyPolyfills: ["regenerator-runtime/runtime"], modernPolyfills: true, }), vue(), vueJsx(), visualizer({ open: true }), // 自动开启分析页面 ], css: { postcss: { plugins: [ postCssPxToRem({ rootValue: 37.5, propList: ["*"], selectorBlackList: [".norem"], }), ], }, }, build: { rollupOptions: { input: { instrument: resolve(__dirname, "instrument.html"), }, output: { chunkFileNames: "js/[name]-[hash].js", // 引入文件名的名称 entryFileNames: "js/[name]-[hash].js", // 包的入口文件名称 assetFileNames: "[ext]/[name]-[hash].[ext]", // 资源文件像 字体,图片等 }, }, }, server: { cors: true, port: 3000, // https: true, proxy: { "^/instrument/.*": { target: "https://test.colexiu.com", changeOrigin: true, rewrite: (path) => path.replace(/^\/instrument/, ""), }, }, }, preview: { port: 3000, host: "192.168.3.114", }, }); // vite.config.js