https://github.com/hxlniada/webpack-hashed-chunkids
a plugin to help webpack to generate unique chunk id based on unique module id
https://github.com/hxlniada/webpack-hashed-chunkids
chunk hash webpack webpack-hashed-chunkids
Last synced: 12 months ago
JSON representation
a plugin to help webpack to generate unique chunk id based on unique module id
- Host: GitHub
- URL: https://github.com/hxlniada/webpack-hashed-chunkids
- Owner: hxlniada
- Created: 2017-12-08T10:08:50.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-22T09:03:13.000Z (about 7 years ago)
- Last Synced: 2025-04-03T15:13:42.789Z (over 1 year ago)
- Topics: chunk, hash, webpack, webpack-hashed-chunkids
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# webpack-hashed-chunkids
[](https://www.npmjs.org/package/webpack-hashed-chunkids)
[](https://www.npmjs.org/package/webpack-hashed-chunkids)
> a plugin to help webpack to generate unique chunk id based on module id
### why
webpack has official plugins to generate a unique module id: [module-identifiers](https://webpack.js.org/guides/caching/#module-identifiers)
but what about chunk id? I can't find a solution.
what is chunk id? open a bundled file, you can find something like this:
```
webpackJsonp([117],{...})
```
and the number 117 is chunk id
### dependencies
* [NamedModulesPlugin](https://webpack.js.org/plugins/named-modules-plugin/) or [HashedModuleIdsPlugin](https://webpack.js.org/plugins/hashed-module-ids-plugin/) or other plugins generate unique module id
### install
```
npm install webpack-hashed-chunkids --save-dev
```
### features
* generate unique chunk id based on unique module id
### usage
```javascript
const HashedChunkidsPlugin = require('webpack-hashed-chunkids');
plugins: [
new webpack.HashedModuleIdsPlugin(),
new HashedChunkidsPlugin({
hashFunction: 'md5', // The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHash are supported.
hashDigest: 'hex', // The encoding to use when generating the hash, defaults to 'hex'. All encodings from Node.JS' hash.digest are supported.
hashDigestLength: 4 // The prefix length of the hash digest to use, defaults to 4.
})
]
```
* [crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options)
* [hash.digest](https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding)