-
Notifications
You must be signed in to change notification settings - Fork 40
Improve Webpack Setup: Adopt Best-Practice Extension for @wordpress/scripts #92
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
Improve Webpack Setup: Adopt Best-Practice Extension for @wordpress/scripts #92
Conversation
Added the 'webpack-remove-empty-scripts' package to dependencies
Added 'start' script to package.json for wp-scripts and included 'webpack-remove-empty-scripts' as a new development dependency.
Added RemoveEmptyScriptsPlugin to remove empty .js files after WordPress asset generation. Updated entry paths to use path.resolve for consistency and maintainability. Refactored config to extend the default WordPress webpack configuration directly.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
dkotter
left a comment
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.
Some JS lint errors that are being flagged but otherwise this looks good and tests well
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
|
Hi @dkotter ,
I’ve reviewed and resolved all the issues. Please take a look when you get a chance. Thanks for your guidance and support! |
What?
This PR updates the Webpack configuration to a production-ready approach for extending @wordpress/scripts.
Key changes:
entryandpluginsRemoveEmptyScriptsPluginto eliminate empty JS files from SCSS-only entriespath.resolvefor safer path handlingWhy?
The previous configuration extended only the
entryproperty and used relative paths.This resulted in:
.jsfiles generated by SCSS entriesThe improved configuration aligns with modern WordPress tooling practices and keeps the build output cleaner, more stable, and more maintainable.
How?
RemoveEmptyScriptsPlugin...defaultConfig.pluginspath.resolveTesting Instructions
npm run build.jsfiles are generated for SCSS-only entries.cssand.jsassets are correctly builtnpm run startand confirm:build/directory and ensure the output is clean, consistent, and free of unnecessary filesFixed #91