Skip to content

Commit

Permalink
feat: 生产环境 gzip 压缩
Browse files Browse the repository at this point in the history
  • Loading branch information
yulimchen committed Feb 7, 2023
1 parent f44bc07 commit ad884b9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"typescript": "~4.7.4",
"unplugin-vue-components": "^0.22.12",
"vite": "^4.0.0",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-mock-dev-server": "^0.3.16",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-setup-extend": "^0.4.0",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import path from "path";
import mockDevServerPlugin from "vite-plugin-mock-dev-server";
import vueSetupExtend from "vite-plugin-vue-setup-extend";
import viteCompression from "vite-plugin-compression";

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -27,7 +28,9 @@ export default defineConfig({
symbolId: "icon-[dir]-[name]"
}),
// 允许 setup 语法糖上添加组件名属性
vueSetupExtend()
vueSetupExtend(),
// 生成环境 gzip 压缩资源
viteCompression()
],
resolve: {
alias: {
Expand All @@ -42,5 +45,14 @@ export default defineConfig({
target: ""
}
}
},
build: {
rollupOptions: {
output: {
chunkFileNames: "static/js/[name]-[hash].js",
entryFileNames: "static/js/[name]-[hash].js",
assetFileNames: "static/[ext]/[name]-[hash].[ext]"
}
}
}
});

0 comments on commit ad884b9

Please sign in to comment.