Skip to content

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

Closed
@billyjanitsch

Description

@billyjanitsch

Bug report

What is the current 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. 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-contrib/image-minimizer-webpack-plugin#217.)

If the current behavior is a bug, please provide the steps to reproduce.

Here is a minimal reproduction. See the readme and test file for details.

What is the expected behavior?

The emitted filename should always the same, regardless of whether emit is set to true or false. See the failing test case in the repo.

Other relevant information:
webpack version: 5.40.0
Node.js version: 14.17.0
Operating System: macOS
Additional tools:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions