Substitute a webpack-style hash template string. [hash:7]->abcdefg
npm install hash-replace

Substitute a webpack-style hash template string.
``sh`
$ npm install hash-replace --save
`js
import replace from 'hash-replace'
const r = replace('hash')
// example-1
// only replace [hash], but not [chunkhash]
r('file.[hash:7].[chunkhash]', 'aGFzaC1yZXBsYWNl')
// -> 'file.aGFzaC1.[chunkhash]'
// example-2
// If the second argument is null, then it will generate hash from the
// value of the third argument
r('file.[hash:7].js', null, '1234567')
// -> 'file.fcea920.js'
`
- hashName StringString
- template String=md5
- hashType defaults to 'md5'String
- hashName if the value of template.hashName and hashName not matches, the template will not be substituted.String=hex
- digestType defaults to 'hex'Number=Number.POSITIVE_INFINITY
- maxLength maximum length of the hash. If unset, there will no limit.
The template has the following structure:
`js`
'[hash]'
'[hashName:maxLength]'
'[hashType:hashName:digestType]'
'[hashType:hashName:digestType:maxLength]'
And example-2 is equivalent to:
`js`
r('file.[md5:hash:hex:7].js', null, '1234567')
- replacer String=|function(match, hashType, digestType, length)=
`js`
const r = replace('contenthash')
const filename =
r('file.[contenthash:7].js', null, fileContent)
- content String=|Buffer= If replacer is unset, it will try to digest the content` to get the crypted hash.
MIT