feat: the `resourceQuery` is passed to the `interpolateName` method (โ€ฆ ยท webpack/loader-utils@cd0e428

@@ -197,52 +197,66 @@ In loader context `[hash]` and `[contenthash]` are the same, but we recommend us

197197

Examples

198198199199

``` javascript

200-

// loaderContext.resourcePath = "/app/js/javascript.js"

200+

// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"

201201

loaderUtils.interpolateName(loaderContext, "js/[hash].script.[ext]", { content: ... });

202202

// => js/9473fdd0d880a43c21b7778d34872157.script.js

203203204-

// loaderContext.resourcePath = "/app/js/javascript.js"

204+

// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"

205205

// loaderContext.resourceQuery = "?foo=bar"

206206

loaderUtils.interpolateName(loaderContext, "js/[hash].script.[ext][query]", { content: ... });

207207

// => js/9473fdd0d880a43c21b7778d34872157.script.js?foo=bar

208208209-

// loaderContext.resourcePath = "/app/js/javascript.js"

209+

// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"

210210

loaderUtils.interpolateName(loaderContext, "js/[contenthash].script.[ext]", { content: ... });

211211

// => js/9473fdd0d880a43c21b7778d34872157.script.js

212212213-

// loaderContext.resourcePath = "/app/page.html"

213+

// loaderContext.resourcePath = "/absolute/path/to/app/page.html"

214214

loaderUtils.interpolateName(loaderContext, "html-[hash:6].html", { content: ... });

215215

// => html-9473fd.html

216216217-

// loaderContext.resourcePath = "/app/flash.txt"

217+

// loaderContext.resourcePath = "/absolute/path/to/app/flash.txt"

218218

loaderUtils.interpolateName(loaderContext, "[hash]", { content: ... });

219219

// => c31e9820c001c9c4a86bce33ce43b679

220220221-

// loaderContext.resourcePath = "/app/img/image.gif"

221+

// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif"

222222

loaderUtils.interpolateName(loaderContext, "[emoji]", { content: ... });

223223

// => ๐Ÿ‘

224224225-

// loaderContext.resourcePath = "/app/img/image.gif"

225+

// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif"

226226

loaderUtils.interpolateName(loaderContext, "[emoji:4]", { content: ... });

227227

// => ๐Ÿ™๐Ÿข๐Ÿ“ค๐Ÿ

228228229-

// loaderContext.resourcePath = "/app/img/image.png"

229+

// loaderContext.resourcePath = "/absolute/path/to/app/img/image.png"

230230

loaderUtils.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

233233234-

// loaderContext.resourcePath = "/app/img/myself.png"

234+

// loaderContext.resourcePath = "/absolute/path/to/app/img/myself.png"

235235

// loaderContext.query.name =

236236

loaderUtils.interpolateName(loaderContext, "picture.png");

237237

// => picture.png

238238239-

// loaderContext.resourcePath = "/app/dir/file.png"

239+

// loaderContext.resourcePath = "/absolute/path/to/app/dir/file.png"

240240

loaderUtils.interpolateName(loaderContext, "[path][name].[ext]?[hash]", { content: ... });

241241

// => /app/dir/file.png?9473fdd0d880a43c21b7778d34872157

242242243-

// loaderContext.resourcePath = "/app/js/page-home.js"

243+

// loaderContext.resourcePath = "/absolute/path/to/app/js/page-home.js"

244244

loaderUtils.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

```

247261248262

### `getHashDigest`