vite-plugin-compression icon indicating copy to clipboard operation
vite-plugin-compression copied to clipboard

Feature request: skip if compressed content is larger than original

Open vHeemstra opened this issue 2 years ago • 5 comments

Add something like:

if (size >= oldSize) {
  return
}

at:

https://github.com/vbenjs/vite-plugin-compression/blob/077eff37f45f12896326d687aa0e08f99b2b7a07/packages/core/src/index.ts#L99

To avoid deleting the original file if it will be skipped because of compressed size being larger, move these lines:

https://github.com/vbenjs/vite-plugin-compression/blob/077eff37f45f12896326d687aa0e08f99b2b7a07/packages/core/src/index.ts#L89-L91

after the suggested check code above.

See #36 for fix.

vHeemstra avatar Jun 22 '23 11:06 vHeemstra