File tree 1 file changed +26
-2
lines changed
src/content/configuration
1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -306,10 +306,34 @@ W> `cache.idleTimeoutForInitialStore` is only available when [`cache.store`](#ca
306
306
307
307
` object `
308
308
309
- Expose custom values into the loader context.
309
+ Expose custom values into the [ loader context] ( /api/loaders/#the-loader-context ) .
310
310
311
- ?> Add an example...
311
+ For example, you can define a new variable in the loader context:
312
312
313
+ __ webpack.config.js__
314
+
315
+ ``` javascript
316
+ module .exports = {
317
+ // ...
318
+ loader: {
319
+ answer: 42
320
+ }
321
+ };
322
+ ```
323
+
324
+ Then use ` this.answer ` to get its value in the loader:
325
+
326
+ __ custom-loader.js__
327
+
328
+ ``` javascript
329
+ module .exports = function (source ) {
330
+ // ...
331
+ console .log (this .answer ); // will log `42` here
332
+ return source;
333
+ };
334
+ ```
335
+
336
+ T> You can override properties in the loader context as webpack copies all properties that are defined in the ` loader ` to the loader context.
313
337
314
338
## ` parallelism `
315
339
You can’t perform that action at this time.
0 commit comments