From 0c84e34876d87636dc96f56ac4109830a65ac813 Mon Sep 17 00:00:00 2001 From: Fabian Ehrentraud Date: Sat, 20 Jul 2019 08:26:19 +0200 Subject: [PATCH] feat: added documentation for the postTransformPublicPath option --- README.md | 26 ++++++++++++++++++++++++++ src/options.json | 1 + 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index c93f2f1..b2124e6 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/src/options.json b/src/options.json index f532072..6bbc8a0 100644 --- a/src/options.json +++ b/src/options.json @@ -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)"