mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-02 03:57:37 +08:00
26 lines
574 B
TypeScript
26 lines
574 B
TypeScript
|
import compression from 'vite-plugin-compression'
|
||
|
|
||
|
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,
|
||
|
}),
|
||
|
)
|
||
|
}
|
||
|
return plugin
|
||
|
}
|