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

module.rule.generator.emit = false results in different emitted filenames #217

Closed
billyjanitsch opened this issue Jun 23, 2021 · 8 comments

Comments

@billyjanitsch
Copy link

  • Operating System: macOS
  • Node Version: 14.17.0
  • NPM Version: 7.18.1
  • webpack Version: 5.40.0
  • image-minimizer-webpack-plugin Version: 2.2.0

Expected Behavior

When module.rule.generator.emit is set to false for asset resources, webpack is supposed to emit the same filename as when it's set to true.

Actual Behavior

This doesn't work correctly if there's an image minimizer in the chain, presumably because the minifier is only running when {emit: true} and ends up influencing the asset hash.

Note that this reproduces regardless of the asset filename, e.g., setting it to something like [contenthash][ext] does not fix the issue.

Not sure if this bug is specific to image-minimizer-webpack-plugin or generally an issue with webpack, so I'm reporting it in both places. (See webpack/webpack#13628.)

Code

Here is a minimal reproduction repo.

How Do We Reproduce?

See the readme and test file in the repo for details.

@alexander-akait
Copy link
Member

Please do not duplicate issues

@alexander-akait
Copy link
Member

@alexander-akait
Copy link
Member

Please add configuration for https://github.com/billyjanitsch/webpack-bug-emit-hash

@billyjanitsch
Copy link
Author

The configuration is here.

@alexander-akait
Copy link
Member

We prepare big refactor of the plugin and loader in near future, and will solve this problem, right now please disable loader https://github.com/webpack-contrib/image-minimizer-webpack-plugin#standalone-plugin

@billyjanitsch
Copy link
Author

Thank you for the fast reply.

Disabling loader does not fix the issue. See this commit; the test still fails.

@alexander-akait
Copy link
Member

I will look at this deeply in near future

@alexander-akait
Copy link
Member

Fixed, sorry for big delay, we rewrite plugin from scratch and now have better support asset modules, here example to generate webp and oprimize images, please try https://github.com/webpack-contrib/image-minimizer-webpack-plugin#optimize-and-generate-webp-images

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