docs: add AssetLoggerPlugin example to writing-a-plugin guide#7988
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hello maintainer.... This PR adds a simple plugin example to help beginners |
| ```js | ||
| class AssetLoggerPlugin { | ||
| apply(compiler) { | ||
| compiler.hooks.emit.tap("AssetLoggerPlugin", (compilation) => { |
There was a problem hiding this comment.
Thanks for the feedback! I’ve updated the example to use the
thisCompilation and processAssets hooks instead of the deprecated emit hook.
alexander-akait
left a comment
There was a problem hiding this comment.
Please fix lint problems
| (assets) => { | ||
| console.log("Generated assets:"); | ||
| for (const assetName of Object.keys(assets)) { | ||
| console.log(assetName); |
There was a problem hiding this comment.
webpack has own logger interface please use it here
There was a problem hiding this comment.
Thanks for the feedback!
I’ve updated the AssetLoggerPlugin example to use the Webpack logger interface ( compilation.getLogger ) instead of console.log . The plugin now logs all generated assets using Webpack's official logger.
Please let me know if any further improvements are needed.
This PR adds a minimal Webpack plugin example (AssetLoggerPlugin) to the "Writing a Plugin" guide.
The example demonstrates how to use the emit hook to log generated assets during compilation. This helps beginners understand Webpack plugin hooks and plugin architecture.