Skip to content

feat (webpack-image-sizes-plugin): adds option to silence console output #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

firestar300
Copy link
Contributor

@firestar300 firestar300 commented Jun 3, 2025

Allows users to suppress console output from the plugin.

This adds a silence option to the plugin configuration, which, when set to true, will prevent most console logs from being printed. This can be useful in environments where excessive logging is undesirable.

Summary by Sourcery

Add a silence configuration flag to WebpackImageSizesPlugin to globally suppress console logs, implement a conditional logging wrapper, and update the default plugin setup to use this option.

New Features:

  • Add silence option to WebpackImageSizesPlugin to suppress console output when enabled

Enhancements:

  • Introduce a conditional log method and replace all direct console calls to respect the silence flag

Documentation:

  • Update constructor JSDoc to document the new silence option

Chores:

  • Enable silence: true by default in plugin instantiation within config/plugins.js

Allows users to suppress console output from the plugin.

This adds a `silence` option to the plugin configuration, which, when set to `true`, will prevent most console logs from being printed. This can be useful in environments where excessive logging is undesirable.
Copy link

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

Adds a new silence boolean option to the WebpackImageSizesPlugin, implements a centralized log() wrapper to respect this setting, and replaces all direct console calls with conditional logging while updating the default plugin instantiation to enable silence.

Sequence Diagram for Conditional Logging Logic

sequenceDiagram
  participant Caller
  participant Plugin as WebpackImageSizesPlugin
  participant Console

  Caller->>Plugin: invokes method (e.g., apply())
  Plugin->>Plugin: log("info", "Log message")
  alt this.options.silence == false
    Plugin->>Console: console.info("Log message")
  else this.options.silence == true
    %% No action for console output
  end
Loading

File-Level Changes

Change Details Files
Add silence configuration option
  • Extend JSDoc and constructor to accept and default options.silence
  • Annotate the pre-instantiation sharp warning as unaffected by silence
config/webpack-image-sizes-plugin.js
Implement log() helper method
  • Introduce log(level, ...args) method to conditionally invoke console[level]
  • Support log, warn, and error levels based on this.options.silence
config/webpack-image-sizes-plugin.js
Replace direct console calls with this.log()
  • Swap out console.log, console.warn, and console.error across generation, watch, parsing, and default image routines
  • Ensure all original messages and arguments are preserved when delegated
config/webpack-image-sizes-plugin.js
Update default plugin instantiation to enable silence
  • Add silence: true in config/plugins.js example array
config/plugins.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @firestar300 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@remicorsonbeapi remicorsonbeapi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@firestar300 firestar300 merged commit a1e707b into master Jun 3, 2025
0 of 3 checks passed
@firestar300 firestar300 deleted the feature/silence-image-plugin branch June 3, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants