赞
踩
npm install --save-dev rollup-plugin-visualizer
import { defineConfig } from "vite"
import { visualizer } from "rollup-plugin-visualizer"
export default defineConfig({
plugins: [
visualizer({
open: true, //注意这里要设置为true,否则无效
gzipSize: true,
})
],
})
npm i vite-plugin-compression -D
algorithm
:压缩算法,可选 [ ‘gzip’ , ‘brotliCompress’ ,‘deflate’ , ‘deflateRaw’]import viteCompression from 'vite-plugin-compression';
export default () => {
return {
plugins: [
viteCompression({
deleteOriginFile: false,
algorithm: "gzip",
}),
],
};
};
import { defineConfig } from "vite" export default defineConfig({ build: { rollupOptions: { output: { manualChunks: { react: ["react", "react-router-dom"], echarts: ["echarts"], lodash: ["lodash"], antd: ["antd"], moment: ["moment"], ahooks: ["ahooks"], reactJss: ["react-jss"], exceljs: ["exceljs"], html2canvas: ["html2canvas"], }, }, }, }, })
npm add -D terser @vitejs/plugin-legacy
// vite.config.js
import legacy from '@vitejs/plugin-legacy'
export default {
plugins: [
legacy({
targets: ['defaults', 'not IE 11']
})
]
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。