feat: add compress plugin
This commit is contained in:
parent
296d5ea6f0
commit
2f1b747243
@ -8,4 +8,10 @@ VITE_APP_USE_MOCK = true
|
||||
VITE_APP_BASE_API = '/api'
|
||||
|
||||
# test base api
|
||||
VITE_APP_BASE_API_TEST = '/api-test'
|
||||
VITE_APP_BASE_API_TEST = '/api-test'
|
||||
|
||||
# 是否启用压缩
|
||||
VITE_USE_COMPRESS = true
|
||||
|
||||
# 压缩类型
|
||||
VITE_COMPRESS_TYPE = gzip
|
@ -14,6 +14,8 @@ import Unocss from 'unocss/vite'
|
||||
|
||||
// rollup打包分析插件
|
||||
import visualizer from 'rollup-plugin-visualizer'
|
||||
// 压缩
|
||||
import viteCompression from 'vite-plugin-compression'
|
||||
|
||||
import { configHtmlPlugin } from './html'
|
||||
import { configMockPlugin } from './mock'
|
||||
@ -26,6 +28,10 @@ export function createVitePlugins(viteEnv, isBuild) {
|
||||
plugins.push(configMockPlugin(isBuild))
|
||||
}
|
||||
|
||||
if (viteEnv.VITE_USE_COMPRESS) {
|
||||
plugins.push(viteCompression({ algorithm: viteEnv.VITE_COMPRESS_TYPE || 'gzip' }))
|
||||
}
|
||||
|
||||
if (isBuild) {
|
||||
plugins.push(
|
||||
visualizer({
|
||||
|
@ -52,6 +52,7 @@
|
||||
"unplugin-icons": "^0.14.1",
|
||||
"unplugin-vue-components": "^0.17.21",
|
||||
"vite": "^2.9.9",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-html": "^3.2.0",
|
||||
"vite-plugin-mock": "^2.9.6",
|
||||
"vite-plugin-vue-setup-extend-plus": "^0.1.0"
|
||||
|
15
pnpm-lock.yaml
generated
15
pnpm-lock.yaml
generated
@ -35,6 +35,7 @@ specifiers:
|
||||
unplugin-icons: ^0.14.1
|
||||
unplugin-vue-components: ^0.17.21
|
||||
vite: ^2.9.9
|
||||
vite-plugin-compression: ^0.5.1
|
||||
vite-plugin-html: ^3.2.0
|
||||
vite-plugin-mock: ^2.9.6
|
||||
vite-plugin-vue-setup-extend-plus: ^0.1.0
|
||||
@ -80,6 +81,7 @@ devDependencies:
|
||||
unplugin-icons: 0.14.1_jyihscimozjyoh3ugo77i7phoi
|
||||
unplugin-vue-components: 0.17.21_vite@2.9.9+vue@3.2.31
|
||||
vite: 2.9.9_sass@1.49.10
|
||||
vite-plugin-compression: 0.5.1_vite@2.9.9
|
||||
vite-plugin-html: 3.2.0_vite@2.9.9
|
||||
vite-plugin-mock: 2.9.6_mockjs@1.1.0+vite@2.9.9
|
||||
vite-plugin-vue-setup-extend-plus: 0.1.0
|
||||
@ -4283,6 +4285,19 @@ packages:
|
||||
vue: 3.2.31
|
||||
dev: true
|
||||
|
||||
/vite-plugin-compression/0.5.1_vite@2.9.9:
|
||||
resolution: {integrity: sha512-5QJKBDc+gNYVqL/skgFAP81Yuzo9R+EAf19d+EtsMF/i8kFUpNi3J/H01QD3Oo8zBQn+NzoCIFkpPLynoOzaJg==}
|
||||
peerDependencies:
|
||||
vite: '>=2.0.0'
|
||||
dependencies:
|
||||
chalk: 4.1.2
|
||||
debug: 4.3.4
|
||||
fs-extra: 10.0.1
|
||||
vite: 2.9.9_sass@1.49.10
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/vite-plugin-html/3.2.0_vite@2.9.9:
|
||||
resolution: {integrity: sha512-2VLCeDiHmV/BqqNn5h2V+4280KRgQzCFN47cst3WiNK848klESPQnzuC3okH5XHtgwHH/6s1Ho/YV6yIO0pgoQ==}
|
||||
peerDependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user