Skip to content

Plugin Directory: Skip the CSS source map in the production build#667

Closed
derpaschi wants to merge 2 commits into
WordPress:trunkfrom
derpaschi:fix/wporg-plugins-theme-no-css-source-maps-for-build
Closed

Plugin Directory: Skip the CSS source map in the production build#667
derpaschi wants to merge 2 commits into
WordPress:trunkfrom
derpaschi:fix/wporg-plugins-theme-no-css-source-maps-for-build

Conversation

@derpaschi
Copy link
Copy Markdown

@derpaschi derpaschi commented Jun 4, 2026

What

The grunt build task (run via npm run build:css) was still writing a css/style.css.map file, even though source maps aren't intended for the built/production CSS.

This adjusts the grunt-sass sourceMap option so the map is generated only for the local development tasks (grunt / grunt watch) and is skipped during grunt build:

sourceMap: 'build' !== process.argv[ 2 ],
omitSourceMapUrl: 'build' === process.argv[ 2 ],

Why

omitSourceMapUrl only strips the sourceMappingURL comment from style.css; it doesn't stop grunt-sass from writing the .map file itself. The previous condition evaluated to true during build, so a style.css.map was 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) → no css/style.css.map is produced, and style.css contains no sourceMappingURL comment.
  • 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.

Copilot AI review requested due to automatic review settings June 4, 2026 12:44
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props hubersen.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 sourceMap generation based on whether the build task 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.

Comment on lines +23 to 24
sourceMap: 'build' !== process.argv[ 2 ],
omitSourceMapUrl: 'build' === process.argv[ 2 ],
Comment thread wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/Gruntfile.js Outdated
@bazza bazza closed this in 978facd Jun 4, 2026
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