mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-04 21:18:16 +08:00
vite-plugin-compression2 替换 vite-plugin-compression
This commit is contained in:
parent
738c74d1c4
commit
2e34d88d94
@ -100,7 +100,7 @@
|
||||
"unplugin-vue-components": "^0.26.0",
|
||||
"vite": "^5.0.11",
|
||||
"vite-plugin-banner": "^0.7.1",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-compression2": "^0.11.0",
|
||||
"vite-plugin-fake-server": "^2.1.0",
|
||||
"vite-plugin-pages": "^0.32.0",
|
||||
"vite-plugin-svg-icons": "^2.0.1",
|
||||
|
@ -256,9 +256,9 @@ devDependencies:
|
||||
vite-plugin-banner:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
vite-plugin-compression:
|
||||
specifier: ^0.5.1
|
||||
version: 0.5.1(vite@5.0.11)
|
||||
vite-plugin-compression2:
|
||||
specifier: ^0.11.0
|
||||
version: 0.11.0
|
||||
vite-plugin-fake-server:
|
||||
specifier: ^2.1.0
|
||||
version: 2.1.0
|
||||
@ -11691,17 +11691,12 @@ packages:
|
||||
resolution: {integrity: sha512-Bww2Xd5tOGsZ1yZ9rQiGneryvsL1u86znPrqeQjCsXPsG72pnSdV5lcQA+cy8UNDguMqyTJiCevlNUbLnT85UA==}
|
||||
dev: true
|
||||
|
||||
/vite-plugin-compression@0.5.1(vite@5.0.11):
|
||||
resolution: {integrity: sha512-5QJKBDc+gNYVqL/skgFAP81Yuzo9R+EAf19d+EtsMF/i8kFUpNi3J/H01QD3Oo8zBQn+NzoCIFkpPLynoOzaJg==}
|
||||
peerDependencies:
|
||||
vite: '>=2.0.0'
|
||||
/vite-plugin-compression2@0.11.0:
|
||||
resolution: {integrity: sha512-U6oEyRXZD26BynOgD/tStNTbQOLPt96aQNj/gdJTicKVYCQCdlV7QdmSF7VEhSyjiS59pQRhiMBu/uajprxWLA==}
|
||||
dependencies:
|
||||
chalk: 4.1.2
|
||||
debug: 4.3.4
|
||||
fs-extra: 10.1.0
|
||||
vite: 5.0.11(sass@1.69.7)(terser@5.26.0)
|
||||
'@rollup/pluginutils': 5.1.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
- rollup
|
||||
dev: true
|
||||
|
||||
/vite-plugin-fake-server@2.1.0:
|
||||
|
@ -1,25 +1,24 @@
|
||||
import compression from 'vite-plugin-compression'
|
||||
import { compression } from 'vite-plugin-compression2'
|
||||
import type { PluginOption } from 'vite'
|
||||
|
||||
export default function createCompression(env) {
|
||||
const { VITE_BUILD_COMPRESS } = env
|
||||
const compressList = VITE_BUILD_COMPRESS.split(',')
|
||||
const plugin: any[] = []
|
||||
if (compressList.includes('gzip')) {
|
||||
plugin.push(
|
||||
compression({
|
||||
ext: '.gz',
|
||||
deleteOriginFile: false,
|
||||
}),
|
||||
)
|
||||
}
|
||||
if (compressList.includes('brotli')) {
|
||||
plugin.push(
|
||||
compression({
|
||||
ext: '.br',
|
||||
algorithm: 'brotliCompress',
|
||||
deleteOriginFile: false,
|
||||
}),
|
||||
)
|
||||
export default function createCompression(env, isBuild) {
|
||||
const plugin: (PluginOption | PluginOption[])[] = []
|
||||
if (isBuild) {
|
||||
const { VITE_BUILD_COMPRESS } = env
|
||||
const compressList = VITE_BUILD_COMPRESS.split(',')
|
||||
if (compressList.includes('gzip')) {
|
||||
plugin.push(
|
||||
compression(),
|
||||
)
|
||||
}
|
||||
if (compressList.includes('brotli')) {
|
||||
plugin.push(
|
||||
compression({
|
||||
exclude: [/\.(br)$/, /\.(gz)$/],
|
||||
algorithm: 'brotliCompress',
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
return plugin
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export default function createVitePlugins(viteEnv, isBuild = false) {
|
||||
vitePlugins.push(createMock(viteEnv, isBuild))
|
||||
vitePlugins.push(createLayouts())
|
||||
vitePlugins.push(createPages())
|
||||
isBuild && vitePlugins.push(...createCompression(viteEnv))
|
||||
vitePlugins.push(...createCompression(viteEnv, isBuild))
|
||||
vitePlugins.push(createConsole())
|
||||
vitePlugins.push(createBanner())
|
||||
return vitePlugins
|
||||
|
Loading…
Reference in New Issue
Block a user