Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit a38391f

Browse files
committed
feat: added documentation for the postTransformPublicPath option
1 parent 68538bb commit a38391f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,32 @@ module.exports = {
245245
};
246246
```
247247

248+
### `postTransformPublicPath`
249+
250+
Type: `Function`
251+
Default: `undefined`
252+
253+
Specifies a custom function to post-process the generated public path. This can be used to prepend or append dynamic global variables that are only available at runtime, like `__webpack_public_path__`. This would not be possible with just `publicPath`, since it stringifies the values.
254+
255+
**webpack.config.js**
256+
257+
```js
258+
module.exports = {
259+
module: {
260+
rules: [
261+
{
262+
test: /\.(png|jpg|gif)$/,
263+
loader: 'file-loader',
264+
options: {
265+
publicPath: '/some/path/',
266+
postTransformPublicPath: (p) => `__webpack_public_path__ + ${p}`,
267+
},
268+
},
269+
],
270+
},
271+
};
272+
```
273+
248274
### `context`
249275

250276
Type: `String`

src/options.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"name": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#name)",
5656
"outputPath": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#outputpath)",
5757
"publicPath": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#publicpath)",
58+
"postTransformPublicPath": "should be {Function} (https://github.com/webpack-contrib/file-loader#posttransformpublicpath)",
5859
"context": "should be {String} (https://github.com/webpack-contrib/file-loader#context)",
5960
"emitFile": "should be {Boolean} (https://github.com/webpack-contrib/file-loader#emitfile)",
6061
"regExp": "should be {String} or {RegExp} (https://github.com/webpack-contrib/file-loader#regexp)"

0 commit comments

Comments
 (0)