@@ -197,52 +197,66 @@ In loader context `[hash]` and `[contenthash]` are the same, but we recommend us |
197 | 197 | Examples |
198 | 198 |
|
199 | 199 | ``` javascript |
200 | | -// loaderContext.resourcePath = "/app/js/javascript.js" |
| 200 | +// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js" |
201 | 201 | loaderUtils.interpolateName(loaderContext, "js/[hash].script.[ext]", { content: ... }); |
202 | 202 | // => js/9473fdd0d880a43c21b7778d34872157.script.js |
203 | 203 |
|
204 | | -// loaderContext.resourcePath = "/app/js/javascript.js" |
| 204 | +// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js" |
205 | 205 | // loaderContext.resourceQuery = "?foo=bar" |
206 | 206 | loaderUtils.interpolateName(loaderContext, "js/[hash].script.[ext][query]", { content: ... }); |
207 | 207 | // => js/9473fdd0d880a43c21b7778d34872157.script.js?foo=bar |
208 | 208 |
|
209 | | -// loaderContext.resourcePath = "/app/js/javascript.js" |
| 209 | +// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js" |
210 | 210 | loaderUtils.interpolateName(loaderContext, "js/[contenthash].script.[ext]", { content: ... }); |
211 | 211 | // => js/9473fdd0d880a43c21b7778d34872157.script.js |
212 | 212 |
|
213 | | -// loaderContext.resourcePath = "/app/page.html" |
| 213 | +// loaderContext.resourcePath = "/absolute/path/to/app/page.html" |
214 | 214 | loaderUtils.interpolateName(loaderContext, "html-[hash:6].html", { content: ... }); |
215 | 215 | // => html-9473fd.html |
216 | 216 |
|
217 | | -// loaderContext.resourcePath = "/app/flash.txt" |
| 217 | +// loaderContext.resourcePath = "/absolute/path/to/app/flash.txt" |
218 | 218 | loaderUtils.interpolateName(loaderContext, "[hash]", { content: ... }); |
219 | 219 | // => c31e9820c001c9c4a86bce33ce43b679 |
220 | 220 |
|
221 | | -// loaderContext.resourcePath = "/app/img/image.gif" |
| 221 | +// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif" |
222 | 222 | loaderUtils.interpolateName(loaderContext, "[emoji]", { content: ... }); |
223 | 223 | // => 👍 |
224 | 224 |
|
225 | | -// loaderContext.resourcePath = "/app/img/image.gif" |
| 225 | +// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif" |
226 | 226 | loaderUtils.interpolateName(loaderContext, "[emoji:4]", { content: ... }); |
227 | 227 | // => 🙍🏢📤🐝 |
228 | 228 |
|
229 | | -// loaderContext.resourcePath = "/app/img/image.png" |
| 229 | +// loaderContext.resourcePath = "/absolute/path/to/app/img/image.png" |
230 | 230 | loaderUtils.interpolateName(loaderContext, "[sha512:hash:base64:7].[ext]", { content: ... }); |
231 | 231 | // => 2BKDTjl.png |
232 | 232 | // use sha512 hash instead of md5 and with only 7 chars of base64 |
233 | 233 |
|
234 | | -// loaderContext.resourcePath = "/app/img/myself.png" |
| 234 | +// loaderContext.resourcePath = "/absolute/path/to/app/img/myself.png" |
235 | 235 | // loaderContext.query.name = |
236 | 236 | loaderUtils.interpolateName(loaderContext, "picture.png"); |
237 | 237 | // => picture.png |
238 | 238 |
|
239 | | -// loaderContext.resourcePath = "/app/dir/file.png" |
| 239 | +// loaderContext.resourcePath = "/absolute/path/to/app/dir/file.png" |
240 | 240 | loaderUtils.interpolateName(loaderContext, "[path][name].[ext]?[hash]", { content: ... }); |
241 | 241 | // => /app/dir/file.png?9473fdd0d880a43c21b7778d34872157 |
242 | 242 |
|
243 | | -// loaderContext.resourcePath = "/app/js/page-home.js" |
| 243 | +// loaderContext.resourcePath = "/absolute/path/to/app/js/page-home.js" |
244 | 244 | loaderUtils.interpolateName(loaderContext, "script-[1].[ext]", { regExp: "page-(.*)\\.js", content: ... }); |
245 | 245 | // => 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 |
246 | 260 | ``` |
247 | 261 |
|
248 | 262 | ### `getHashDigest` |
|