index.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { Plugin } from 'vite';
  2. import { ZlibOptions, BrotliOptions } from 'zlib';
  3. declare type Algorithm = 'gzip' | 'brotliCompress' | 'deflate' | 'deflateRaw';
  4. declare type CompressionOptions = Partial<ZlibOptions> | Partial<BrotliOptions>;
  5. interface VitePluginCompression {
  6. /**
  7. * Log compressed files and their compression ratios.
  8. * @default: true
  9. */
  10. verbose?: boolean;
  11. /**
  12. * Minimum file size before compression is used.
  13. * @default 1025
  14. */
  15. threshold?: number;
  16. /**
  17. * Filter files that do not need to be compressed
  18. * @default /\.(js|mjs|json|css|html)$/i
  19. */
  20. filter?: RegExp | ((file: string) => boolean);
  21. /**
  22. * Whether to enable compression
  23. * @default: false
  24. */
  25. disable?: boolean;
  26. /**
  27. * Compression algorithm
  28. * @default gzip
  29. */
  30. algorithm?: Algorithm;
  31. /**
  32. * File format after compression
  33. * @default .gz
  34. */
  35. ext?: string;
  36. /**
  37. * Compression Options
  38. */
  39. compressionOptions?: CompressionOptions;
  40. /**
  41. * Delete the corresponding source file after compressing the file
  42. * @default: false
  43. */
  44. deleteOriginFile?: boolean;
  45. /**
  46. * success callback after completed
  47. */
  48. success?: () => void;
  49. }
  50. declare function export_default(options?: VitePluginCompression): Plugin;
  51. export { export_default as default };