@@ -197,52 +197,66 @@ In loader context `[hash]` and `[contenthash]` are the same, but we recommend us
197197Examples
198198
199199``` javascript
200- // loaderContext.resourcePath = "/app/js/javascript.js"
200+ // loaderContext.resourcePath = "/absolute/path/to/ app/js/javascript.js"
201201loaderUtils .interpolateName (loaderContext, " js/[hash].script.[ext]" , { content: ... });
202202// => js/9473fdd0d880a43c21b7778d34872157.script.js
203203
204- // loaderContext.resourcePath = "/app/js/javascript.js"
204+ // loaderContext.resourcePath = "/absolute/path/to/ app/js/javascript.js"
205205// loaderContext.resourceQuery = "?foo=bar"
206206loaderUtils .interpolateName (loaderContext, " js/[hash].script.[ext][query]" , { content: ... });
207207// => js/9473fdd0d880a43c21b7778d34872157.script.js?foo=bar
208208
209- // loaderContext.resourcePath = "/app/js/javascript.js"
209+ // loaderContext.resourcePath = "/absolute/path/to/ app/js/javascript.js"
210210loaderUtils .interpolateName (loaderContext, " js/[contenthash].script.[ext]" , { content: ... });
211211// => js/9473fdd0d880a43c21b7778d34872157.script.js
212212
213- // loaderContext.resourcePath = "/app/page.html"
213+ // loaderContext.resourcePath = "/absolute/path/to/ app/page.html"
214214loaderUtils .interpolateName (loaderContext, " html-[hash:6].html" , { content: ... });
215215// => html-9473fd.html
216216
217- // loaderContext.resourcePath = "/app/flash.txt"
217+ // loaderContext.resourcePath = "/absolute/path/to/ app/flash.txt"
218218loaderUtils .interpolateName (loaderContext, " [hash]" , { content: ... });
219219// => c31e9820c001c9c4a86bce33ce43b679
220220
221- // loaderContext.resourcePath = "/app/img/image.gif"
221+ // loaderContext.resourcePath = "/absolute/path/to/ app/img/image.gif"
222222loaderUtils .interpolateName (loaderContext, " [emoji]" , { content: ... });
223223// => 👍
224224
225- // loaderContext.resourcePath = "/app/img/image.gif"
225+ // loaderContext.resourcePath = "/absolute/path/to/ app/img/image.gif"
226226loaderUtils .interpolateName (loaderContext, " [emoji:4]" , { content: ... });
227227// => 🙍🏢📤🐝
228228
229- // loaderContext.resourcePath = "/app/img/image.png"
229+ // loaderContext.resourcePath = "/absolute/path/to/ app/img/image.png"
230230loaderUtils .interpolateName (loaderContext, " [sha512:hash:base64:7].[ext]" , { content: ... });
231231// => 2BKDTjl.png
232232// use sha512 hash instead of md5 and with only 7 chars of base64
233233
234- // loaderContext.resourcePath = "/app/img/myself.png"
234+ // loaderContext.resourcePath = "/absolute/path/to/ app/img/myself.png"
235235// loaderContext.query.name =
236236loaderUtils .interpolateName (loaderContext, " picture.png" );
237237// => picture.png
238238
239- // loaderContext.resourcePath = "/app/dir/file.png"
239+ // loaderContext.resourcePath = "/absolute/path/to/ app/dir/file.png"
240240loaderUtils .interpolateName (loaderContext, " [path][name].[ext]?[hash]" , { content: ... });
241241// => /app/dir/file.png?9473fdd0d880a43c21b7778d34872157
242242
243- // loaderContext.resourcePath = "/app/js/page-home.js"
243+ // loaderContext.resourcePath = "/absolute/path/to/ app/js/page-home.js"
244244loaderUtils .interpolateName (loaderContext, " script-[1].[ext]" , { regExp: " page-(.*)\\ .js" , content: ... });
245245// => script-home.js
246+
247+ // loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"
248+ // loaderContext.resourceQuery = "?foo=bar"
249+ loaderUtils .interpolateName (
250+ loaderContext,
251+ (resourcePath , resourceQuery ) => {
252+ // resourcePath - `/app/js/javascript.js`
253+ // resourceQuery - `?foo=bar`
254+
255+ return " js/[hash].script.[ext]" ;
256+ },
257+ { content: ... }
258+ );
259+ // => js/9473fdd0d880a43c21b7778d34872157.script.js
246260```
247261
248262### ` getHashDigest `
0 commit comments