output.filenameHash

  • Type: boolean | string
  • Default: true
  • Version: >= 0.4.0

Whether to add a hash value to the filename after the production build.

Disable hash

By default, the filename of the output files will include a hash value:

dist/static/css/index.7879e19d.css
dist/static/js/index.18a568e5.js

You can set output.filenameHash to false to disable this behavior:

export default {
  output: {
    filenameHash: false,
  },
};

After rebuilding, the output filenames becomes:

dist/static/css/index.css
dist/static/js/index.js

Hash Format

The default hash format is contenthash:8, which generates an 8-bit hash based on the content of the file.

You can set output.filenameHash to other formats supported by Rspack and customize the length.

export default {
  output: {
    filenameHash: 'fullhash:16',
  },
};

The optional hash formats are:

  • fullhash: The hash value of the entire compilation. If any file changes, the hash values of all output files in the entire project will change.
  • chunkhash: The hash value of the chunk. The hash value will only change when the content of the chunk (and its included modules) changes.
  • contenthash: The hash value of the file content. The hash value will only change when the content of the file itself changes.

Notes

  • output.filename has a higher priority than output.filenameHash.
  • By default, when the target is not web, the hash will not be included in the filename of the output files, such as Node.js bundles.
  • By default, the development build filename does not include a hash.