webpack-custom-stats-patch
This module provides a patched copy of webpack's Stats
prototype, it extends
it to allow you to inject your own custom attributes.
This could be useful when you are writing webpack plugins that generate a specific set of information that you would to pass down to your stat plugins that could be generating things like asset manifests.
For example, you may be writing a webpack plugin to generate subresource
integrity hashes that get saved into some mapping into webpack's compilation
,
but your stats plugin has no way of retrieving the mapping because
stats.toJSON()
returns only a specific set of the compilation
by default [1].
This plugin patches compilation.getStats()
and stats.toJson()
.
You can also reference your custom stats via compilation.__CUSTOM_STATS
.
Install
npm install webpack-custom-stats-patch --save-dev
Usage
var CustomStats = ; var customStats = compilation; // Add a custom statcustomStats; // Now when `stats.toJson()` is called in your stats plugins, the custom stat// is availablecustomStatssris// # => { 'main-123456789.js': 'sha512-9000' }); // You can also view the custom stats directly in compilationcompilation__CUSTOM_STATS// # => {// sris: {// 'main-123456789': 'sha512-9000'// }// }; // Replace custom stats in its entirety// Pass in a plain objectcustomStats;
Special Thanks
LICENSE
MIT.