gzip.ts 444 字节
Newer Older
V
vben 已提交
1 2 3 4 5
/**
 * Used to package and output gzip. Note that this does not work properly in Vite, the specific reason is still being investigated
 */
import type { Plugin } from 'vite';

V
vben 已提交
6 7
import gzipPlugin from 'rollup-plugin-gzip';
import { isBuildGzip } from '../../utils';
V
vben 已提交
8

V
vben 已提交
9
export function configGzipPlugin(isBuild: boolean): Plugin | Plugin[] {
V
vben 已提交
10
  const useGzip = isBuild && isBuildGzip();
V
vben 已提交
11 12 13 14 15 16 17

  if (useGzip) {
    return gzipPlugin();
  }

  return [];
}