2021-02-09 23:47:14 +08:00
|
|
|
/**
|
|
|
|
|
* 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';
|
|
|
|
|
|
2021-01-09 23:28:52 +08:00
|
|
|
import gzipPlugin from 'rollup-plugin-gzip';
|
|
|
|
|
import { isBuildGzip } from '../../utils';
|
2021-02-09 23:47:14 +08:00
|
|
|
|
2021-01-09 23:28:52 +08:00
|
|
|
export function configGzipPlugin(isBuild: boolean): Plugin | Plugin[] {
|
2021-01-11 00:16:44 +08:00
|
|
|
const useGzip = isBuild && isBuildGzip();
|
2021-01-09 23:28:52 +08:00
|
|
|
|
|
|
|
|
if (useGzip) {
|
|
|
|
|
return gzipPlugin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
}
|