Plugin Directory: Skip the CSS source map in the production build#667
Plugin Directory: Skip the CSS source map in the production build#667derpaschi wants to merge 2 commits into
Conversation
…clude source map URL in built version.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the theme’s Grunt Sass configuration so source maps are disabled for build runs while remaining enabled for non-build invocations.
Changes:
- Gate
sourceMapgeneration based on whether thebuildtask is being executed. - Adjust the inline comment to reflect the new behavior (source map + source map URL).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sourceMap: 'build' !== process.argv[ 2 ], | ||
| omitSourceMapUrl: 'build' === process.argv[ 2 ], |
What
The
grunt buildtask (run vianpm run build:css) was still writing acss/style.css.mapfile, even though source maps aren't intended for the built/production CSS.This adjusts the
grunt-sasssourceMapoption so the map is generated only for the local development tasks (grunt/grunt watch) and is skipped duringgrunt build:Why
omitSourceMapUrlonly strips thesourceMappingURLcomment fromstyle.css; it doesn't stopgrunt-sassfrom writing the.mapfile itself. The previous condition evaluated totrueduringbuild, so astyle.css.mapwas emitted on every production build and could end up committed alongside the compiled CSS. Keeping source maps for local development while leaving them out of the build keeps the production output clean and avoids accidentally shipping/committing the map.Testing
npm run build:css(i.e.grunt build) → nocss/style.css.mapis produced, andstyle.csscontains nosourceMappingURLcomment.grunt/grunt watch(local development) → source maps are still generated as before.Notes
Small, build-tooling-only change with no effect on the theme's runtime output. Feedback welcome — happy to adjust if there's a preferred pattern for detecting the build task in this Gruntfile.