1. HashedModuleIdsPlugin
该插件会根据模块的相对路径生成一个四位数的hash作为模块id, 建议用于生产环境。
new webpack.HashedModuleIdsPlugin(options)
1.1. options
类型:obeject
该插件支持以下参数:
hashFunction
:哈希算法,默认为 'md5'。支持 Node.JScrypto.createHash
的所有功能。hashDigest
: 在生成 hash 时使用的编码方式,默认为 'base64'。支持 Node.jshash.digest
的所有编码。hashDigestLength
:哈希摘要的前缀长度,默认为 4。
1.2. 用法
下面是使用该插件的例子:
new webpack.HashedModuleIdsPlugin({
hashFunction: 'sha256',
hashDigest: 'hex',
hashDigestLength: 20
})