Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: skip if compressed content is larger than original #35

Open
vHeemstra opened this issue Jun 22, 2023 · 5 comments
Open

Comments

@vHeemstra
Copy link

vHeemstra commented Jun 22, 2023

Add something like:

if (size >= oldSize) {
  return
}

at:

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

if (deleteOriginFile) {
fs.remove(filePath)
}

after the suggested check code above.

See #36 for fix.

@nonzzz
Copy link

nonzzz commented Jun 25, 2023

I think you can try vite-plugin-compression2. Because this project seem die. I had to reimplement a version :(

@vHeemstra
Copy link
Author

Thanks for the tip! Does vite-plugin-compression2 support the option to skip the compressed version if it is larger than or equal the original version?

@nonzzz
Copy link

nonzzz commented Jun 26, 2023

@vHeemstra Of course. size check

By the way. vite-plugin-compression2 has full unit test and e2e test. And it is consistent with the experience of the webpack version

@vHeemstra
Copy link
Author

I switched to your updated package! It is indeed faster. :)
It works great, but I'm missing the ability to log the processed files (as this original package does).

I just made a PR adding the feature to skip compression if the compressed file size is larger than (or equal to) to original file size.

@nonzzz
Copy link

nonzzz commented Jun 26, 2023

@vHeemstra Ok. i will review your code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants