| 1234567891011121314151617181920212223242526272829 |
- import compression from 'vite-plugin-compression'
- export default function createCompression(env) {
- const {VITE_BUILD_COMPRESS} = env
- const plugin = []
- console.debug(VITE_BUILD_COMPRESS);
- 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
- }
|