You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently exactly one option: `publicPath`.
174
-
If you are using a relative `publicPath` in webpack's [output options](https://webpack.js.org/configuration/output/#output-publicpath) and extracting to a file with the `file-loader`, you might need this to account for the location of your extracted file.
174
+
If you are using a relative `publicPath` in webpack's [output options](https://webpack.js.org/configuration/output/#output-publicpath) and extracting to a file with the `file-loader`, you might need this to account for the location of your extracted file.`publicPath` may be defined as a string or a function that accepts current [loader context](https://webpack.js.org/api/loaders/#the-loader-context) as single argument.
175
175
176
-
Example:
176
+
Example with publicPath option as a string:
177
177
178
178
```js
179
179
module.exports= {
@@ -208,6 +208,42 @@ module.exports = {
208
208
};
209
209
```
210
210
211
+
Example with publicPath option as a function:
212
+
213
+
```js
214
+
module.exports= {
215
+
output: {
216
+
path:path.resolve("./dist"),
217
+
publicPath:"dist/"
218
+
},
219
+
module: {
220
+
rules: [
221
+
{
222
+
test:/\.css$/,
223
+
use: [
224
+
{
225
+
loader:"file-loader",
226
+
options: {
227
+
name:"assets/[name].[ext]",
228
+
},
229
+
},
230
+
{
231
+
loader:"extract-loader",
232
+
options: {
233
+
// dynamically return a relative publicPath based on how deep in directory structure the loaded file is in /src/ directory
0 commit comments