Skip to content

Commit 84a7a33

Browse files
committed
fix: replace deprecated emit hook with processAssets
1 parent da6bdda commit 84a7a33

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/content/contribute/writing-a-plugin.mdx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,19 @@ The following example shows a minimal Webpack plugin that logs all generated ass
372372
```js
373373
class AssetLoggerPlugin {
374374
apply(compiler) {
375-
compiler.hooks.emit.tap("AssetLoggerPlugin", (compilation) => {
376-
console.log("Generated assets:");
377-
for (const assetName of Object.keys(compilation.assets)) {
378-
console.log(assetName);
379-
}
375+
compiler.hooks.thisCompilation.tap("AssetLoggerPlugin", (compilation) => {
376+
compilation.hooks.processAssets.tap(
377+
{
378+
name: "AssetLoggerPlugin",
379+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_SUMMARIZE,
380+
},
381+
(assets) => {
382+
console.log("Generated assets:");
383+
Object.keys(assets).forEach((assetName) => {
384+
console.log(assetName);
385+
});
386+
}
387+
);
380388
});
381389
}
382390
}

0 commit comments

Comments
 (0)