赞
踩
- build: {
- terserOptions: {
- compress: {
- drop_console: true,
- drop_debugger: true,
- },
- },
- rollupOptions: {
- output: {
- //静态资源分类打包
- chunkFileNames: "static/js/[name]-[hash].js",
- entryFileNames: "static/js/[name]-[hash].js",
- assetFileNames: "static/[ext]/[name]-[hash].[ext]",
- manualChunks(id) {
- //静态资源分拆打包
- if (id.includes("node_modules")) {
- return id
- .toString()
- .split("node_modules/")[1]
- .split("/")[0]
- .toString();
- }
- },
- },
- },
- },
- npm i vite-plugin-compression -D
-
- //引入
- import viteCompression from 'vite-plugin-compression'
- //在plugins配置数组里添加gzip插件
- plugins: [viteCompression({
- verbose: true,
- disable: false,
- threshold: 10240,
- algorithm: 'gzip',
- ext: '.gz',
- })],
-
- npm i -g serve //安装服务
- serve -s dist //启动服务跑打包后的静态文件
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。