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

Commit

Permalink
feat: added documentation for the postTransformPublicPath option
Browse files Browse the repository at this point in the history
  • Loading branch information
fabb committed Jul 22, 2019
1 parent 7b24388 commit 0c84e34
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Expand Up @@ -269,6 +269,32 @@ module.exports = {
};
```

### `postTransformPublicPath`

Type: `Function`
Default: `undefined`

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.

**webpack.config.js**

```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/,
loader: 'file-loader',
options: {
publicPath: '/some/path/',
postTransformPublicPath: (p) => `__webpack_public_path__ + ${p}`,
},
},
],
},
};
```

### `context`

Type: `String`
Expand Down
1 change: 1 addition & 0 deletions src/options.json
Expand Up @@ -55,6 +55,7 @@
"name": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#name)",
"outputPath": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#outputpath)",
"publicPath": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#publicpath)",
"postTransformPublicPath": "should be {Function} (https://github.com/webpack-contrib/file-loader#posttransformpublicpath)",
"context": "should be {String} (https://github.com/webpack-contrib/file-loader#context)",
"emitFile": "should be {Boolean} (https://github.com/webpack-contrib/file-loader#emitfile)",
"regExp": "should be {String} or {RegExp} (https://github.com/webpack-contrib/file-loader#regexp)"
Expand Down

0 comments on commit 0c84e34

Please sign in to comment.