12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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: {
- "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: {
- "^/instrument/.*": {
- target: "https://dev.gym.lexiaoya.cn",
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/instrument/, ""),
- },
- },
- },
- preview: {
- port: 3000,
- host: "192.168.3.114",
- },
- });
- // vite.config.js
|