@@ -164,20 +164,31 @@ The following tokens are replaced in the `name` parameter:
164
164
* ` [folder] ` the folder of the resource is in.
165
165
* ` [emoji] ` a random emoji representation of ` options.content `
166
166
* ` [emoji:<length>] ` same as above, but with a customizable number of emojis
167
+ * ` [contenthash] ` the hash of ` options.content ` (Buffer) (by default it's the hex digest of the md5 hash)
168
+ * ` [<hashType>:contenthash:<digestType>:<length>] ` optionally one can configure
169
+ * other ` hashType ` s, i. e. ` sha1 ` , ` md5 ` , ` sha256 ` , ` sha512 `
170
+ * other ` digestType ` s, i. e. ` hex ` , ` base26 ` , ` base32 ` , ` base36 ` , ` base49 ` , ` base52 ` , ` base58 ` , ` base62 ` , ` base64 `
171
+ * and ` length ` the length in chars
167
172
* ` [hash] ` the hash of ` options.content ` (Buffer) (by default it's the hex digest of the md5 hash)
168
173
* ` [<hashType>:hash:<digestType>:<length>] ` optionally one can configure
169
174
* other ` hashType ` s, i. e. ` sha1 ` , ` md5 ` , ` sha256 ` , ` sha512 `
170
175
* other ` digestType ` s, i. e. ` hex ` , ` base26 ` , ` base32 ` , ` base36 ` , ` base49 ` , ` base52 ` , ` base58 ` , ` base62 ` , ` base64 `
171
176
* and ` length ` the length in chars
172
177
* ` [N] ` the N-th match obtained from matching the current file name against ` options.regExp `
173
178
179
+ In loader context ` [hash] ` and ` [contenthash] ` are the same, but we recommend using ` [contenthash] ` for avoid misleading.
180
+
174
181
Examples
175
182
176
183
``` javascript
177
184
// loaderContext.resourcePath = "/app/js/javascript.js"
178
185
loaderUtils .interpolateName (loaderContext, " js/[hash].script.[ext]" , { content: ... });
179
186
// => js/9473fdd0d880a43c21b7778d34872157.script.js
180
187
188
+ // loaderContext.resourcePath = "/app/js/javascript.js"
189
+ loaderUtils .interpolateName (loaderContext, " js/[contenthash].script.[ext]" , { content: ... });
190
+ // => js/9473fdd0d880a43c21b7778d34872157.script.js
191
+
181
192
// loaderContext.resourcePath = "/app/page.html"
182
193
loaderUtils .interpolateName (loaderContext, " html-[hash:6].html" , { content: ... });
183
194
// => html-9473fd.html
0 commit comments