mirror of
https://github.com/chillzhuang/Saber.git
synced 2024-11-28 05:19:27 +08:00
28 lines
633 B
JavaScript
28 lines
633 B
JavaScript
|
import compression from 'vite-plugin-compression'
|
||
|
|
||
|
export default function createCompression (env) {
|
||
|
const { VITE_BUILD_COMPRESS } = env
|
||
|
const plugin = []
|
||
|
if (VITE_BUILD_COMPRESS) {
|
||
|
const compressList = VITE_BUILD_COMPRESS.split(',')
|
||
|
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
|
||
|
}
|