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
In addition to `name` and `stage`, you can pass a `additionalAssets` <Badgetext='5.8.0+' /> option which accepts either a value of `true` or a function with `assets` as parameter:
484
+
#### Additional assets
485
+
486
+
In addition to `name` and `stage`, you can pass an `additionalAssets` <Badgetext='5.8.0+' /> option which accepts either a value of `true` or a callback function that receives `assets` as a first argument:
487
+
488
+
1.`true` — run the provided callback again for assets added later by plugins.
475
489
476
-
1.`true` - Run callback against assets added later by plugins.
490
+
In this mode, the callback will be called multiple times: once for assets added prior to the specified stage, and additional times for assets added by plugins later (on this or next stages).
477
491
478
492
```js
479
493
compilation.hooks.processAssets.tap(
@@ -483,45 +497,65 @@ In addition to `name` and `stage`, you can pass a `additionalAssets` <Badge text
483
497
additionalAssets:true,
484
498
},
485
499
(assets) => {
486
-
// this callback will run against assets added later by plugins.
500
+
// this function will be called multiple times with each bulk of assets
487
501
}
488
502
);
489
503
```
490
504
491
-
2.`(assets) => {}` - Run this specified callback against assets added later by plugins.
505
+
2.`(assets, [callback]) => (void | Promise<void>)` — run the specified callback against assets added by plugins later (on this or next stages). The callback must respect the type of the tap method used (e.g. when used with `tapPromise()`, it should return a promise).
// this callback will run against assets added later by plugins.
513
+
// this function potentially could be called multiple times for assets added on later stages
500
514
},
501
515
},
502
516
(assets) => {
503
-
//code
517
+
//this function will be called once with assets added by plugins on prior stages
504
518
}
505
519
);
506
520
```
507
521
508
-
Here's a list of stages we can use:
509
-
510
-
-`PROCESS_ASSETS_STAGE_ADDITIONAL` - Add additional assets to the compilation.
511
-
-`PROCESS_ASSETS_STAGE_PRE_PROCESS` - Basic preprocessing of the assets.
512
-
-`PROCESS_ASSETS_STAGE_DERIVED` - Derive new assets from the existing assets.
513
-
-`PROCESS_ASSETS_STAGE_ADDITIONS` - Add additional sections to the existing assets e.g. banner or initialization code.
514
-
-`PROCESS_ASSETS_STAGE_OPTIMIZE` - Optimize existing assets in a general way.
515
-
-`PROCESS_ASSETS_STAGE_OPTIMIZE_COUNT` - Optimize the count of existing assets, e.g. by merging them.
516
-
-`PROCESS_ASSETS_STAGE_OPTIMIZE_COMPATIBILITY` - Optimize the compatibility of existing assets, e.g. add polyfills or vendor prefixes.
517
-
-`PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE` - Optimize the size of existing assets, e.g. by minimizing or omitting whitespace.
518
-
-`PROCESS_ASSETS_STAGE_DEV_TOOLING` - Add development tooling to the assets, e.g. by extracting a source map.
519
-
-`PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE` <Badgetext='5.8.0+' /> - Optimize the numbers of existing assets, e.g. by inlining assets into other assets.
520
-
-`PROCESS_ASSETS_STAGE_SUMMARIZE` - Summarize the list of existing assets.
521
-
-`PROCESS_ASSETS_STAGE_OPTIMIZE_HASH` - Optimize the hashes of the assets, e.g. by generating real hashes of the asset content.
522
-
-`PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER` - Optimize the transfer of existing assets, e.g. by preparing a compressed (gzip) file as separate asset.
523
-
-`PROCESS_ASSETS_STAGE_ANALYSE` - Analyze the existing assets.
524
-
-`PROCESS_ASSETS_STAGE_REPORT` - Creating assets for the reporting purposes.
522
+
#### List of asset processing stages
523
+
524
+
Here's a list of supported stages (in the order of processing):
525
+
526
+
-`PROCESS_ASSETS_STAGE_ADDITIONAL` — add additional assets to the compilation.
527
+
-`PROCESS_ASSETS_STAGE_PRE_PROCESS` — basic preprocessing of the assets.
528
+
-`PROCESS_ASSETS_STAGE_DERIVED` — derive new assets from the existing assets.
529
+
-`PROCESS_ASSETS_STAGE_ADDITIONS` — add additional sections to the existing assets e.g. banner or initialization code.
530
+
-`PROCESS_ASSETS_STAGE_OPTIMIZE` — optimize existing assets in a general way.
531
+
-`PROCESS_ASSETS_STAGE_OPTIMIZE_COUNT` — optimize the count of existing assets, e.g. by merging them.
532
+
-`PROCESS_ASSETS_STAGE_OPTIMIZE_COMPATIBILITY` — optimize the compatibility of existing assets, e.g. add polyfills or vendor prefixes.
533
+
-`PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE` — optimize the size of existing assets, e.g. by minimizing or omitting whitespace.
534
+
-`PROCESS_ASSETS_STAGE_DEV_TOOLING` — add development tooling to the assets, e.g. by extracting a source map.
535
+
-`PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE` <Badgetext='5.8.0+' /> — optimize the numbers of existing assets, e.g. by inlining assets into other assets.
536
+
-`PROCESS_ASSETS_STAGE_SUMMARIZE` — summarize the list of existing assets.
537
+
-`PROCESS_ASSETS_STAGE_OPTIMIZE_HASH` — optimize the hashes of the assets, e.g. by generating real hashes of the asset content.
538
+
-`PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER` — optimize the transfer of existing assets, e.g. by preparing a compressed (gzip) file as separate asset.
539
+
-`PROCESS_ASSETS_STAGE_ANALYSE` — analyze the existing assets.
540
+
-`PROCESS_ASSETS_STAGE_REPORT` — creating assets for the reporting purposes.
541
+
542
+
#### Assets info
543
+
544
+
The "asset info" metadata is not automatically provided for this hook. If needed, you will have to resolve this metadata manually using the compilation instance and the provided asset pathname. This will be improved in a future version of the webpack.
0 commit comments