Thanks to visit codestin.com
Credit goes to github.com

Skip to content

optimization.realContentHash does not respect output.hashSalt #16788

@dmichon-msft

Description

@dmichon-msft

Bug report

What is the current behavior?
Assets with [contenthash] in the filename template do not produce different hashes when changing the value of the output.hashSalt webpack configuration property, if optimization.realContentHash is true.

If the current behavior is a bug, please provide the steps to reproduce.
Create a trivial webpack project with a [contenthash] in the output filename template and optimization.realContentHash set to true.
Vary the value of the output.hashSalt property and observe that emitted filenames don't change.

What is the expected behavior?
Changing the value of output.hashSalt should change the results of all filename hashes.

Inspection of the code here:

const hash = createHash(this._hashFunction);
for (const content of assetsContent) {
hash.update(content);
}

Shows that RealContentHashPlugin does not look up outputOptions.hashSalt and apply it to the newly created Hash object.

Other relevant information:
webpack version: 5.75.0
Node.js version: 16.19.1
Operating System: Linux
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