-
Notifications
You must be signed in to change notification settings - Fork 18
webpack image sizes plugin #463
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
base: master
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR refactors the WebpackImageSizesPlugin to streamline default option handling, optimize its execution by skipping redundant runs through build and config-change detection, refactors hook implementations for correct context and parameter usage, and updates the SCSS font mixin import path. Sequence Diagram for WebpackImageSizesPlugin Conditional ExecutionsequenceDiagram
participant C as WebpackCompiler
participant P as WebpackImageSizesPlugin
C->>P: Hook triggered (emit or watchRun) with Compilation
activate P
P->>P: runGeneration(compilation, callback)
alt Initial build OR confImgPath changed in compilation.modifiedFiles
P->>P: Set hasBeenBuiltOnce = true
P->>P: Log "Starting WebpackImageSizesPlugin generation..."
P-->>P: Perform image processing tasks
P->>C: callback()
else Not initial build AND no changes in confImgPath
P->>P: Log "No changes detected in confImgPath"
P-->>P: Skip image generation
P->>C: callback()
end
deactivate P
Updated Class Diagram for WebpackImageSizesPluginclassDiagram
class WebpackImageSizesPlugin {
+boolean hasBeenBuiltOnce$
+constructor(options: Object)
+apply(compiler: WebpackCompiler)
+generateDefaultImages(context: string, imageSizes: Object)
}
State Diagram for WebpackImageSizesPlugin Build StatusstateDiagram-v2
[*] --> NotBuiltYet : Initial State
NotBuiltYet: Plugin has not run successfully yet.
BuiltOnce: Plugin has run successfully at least once.
NotBuiltYet --> BuiltOnce : First successful runGeneration completes
BuiltOnce --> BuiltOnce : Subsequent runGeneration (executes or skips based on changes)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @n-langle - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Traiter les retours de Sourcery. |
Prevent webpack image sizes plugin to be called too many times
Summary by Sourcery
Optimize the WebpackImageSizesPlugin to avoid repeated invocations by tracking build state and file changes, streamline its initialization logic, and correct the SCSS import path for Poppins font mixins.
Enhancements: