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: { gym: resolve(__dirname, "index.html"), colexiu: resolve(__dirname, "colexiu.html"), orchestra: resolve(__dirname, "orchestra.html"), "report-share": resolve(__dirname, "report-share.html"), 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: { "^/gym/.*": { target: "https://mstutest.dayaedu.com", // target: "https://online.dayaedu.com", changeOrigin: true, rewrite: (path) => path.replace(/^\/gym/, ""), }, "^/colexiu/.*": { target: "https://dev.colexiu.com", // target: "https://online.colexiu.com", changeOrigin: true, rewrite: (path) => path.replace(/^\/colexiu/, ""), }, "^/orchestra/.*": { target: "https://test.lexiaoya.cn", changeOrigin: true, rewrite: (path) => path.replace(/^\/orchestra/, ""), }, "^/instrument/.*": { // target: "https://kt.colexiu.com", // target: "https://test.lexiaoya.cn", // target: "https://kt.colexiu.com", target: "https://test.resource.colexiu.com", // 内容平台开发环境,内容平台开发,需在url链接上加上isCbs=true //target: "https://test.kt.colexiu.com", // target: "https://mec.colexiu.com", changeOrigin: true, rewrite: (path) => path.replace(/^\/instrument/, ""), }, }, }, preview: { port: 3000, host: "192.168.3.114", }, }); // vite.config.js