Skip to content

Conversation

@manzoorwanijk
Copy link
Member

Currently, when working with CSS modules, the generated class names are base64 hash which are unreadable while debugging. So, it is helpful to have the classnames retained during development.

Slack: p1764235570543949-slack-C05Q5HSS013

Proposed changes:

  • Update the global webpack config to update localIdentName for CSS modules for development.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Run jetpack watch plugins/jetpack
  • Review some of the pages to ensure they work fine
  • Confirm that CSS modules have class name in them
  • Run jetpack build plugins/jetpack
  • Confirm that the UIs work fine

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/local-name-for-css-module-classes-for-dev branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/local-name-for-css-module-classes-for-dev
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/local-name-for-css-module-classes-for-dev

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

Copy link
Contributor

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

This PR enhances the webpack configuration for CSS modules to improve developer experience during debugging. It adds a default configuration that retains human-readable local class names in development builds (e.g., button--a1b2c instead of just a1b2c), making it easier to identify and debug CSS module classes in browser DevTools.

Key Changes:

  • Adds default CSS modules configuration with auto: true to enable automatic CSS module detection for files with .module.* in their names
  • Implements environment-aware localIdentName patterns: readable names in development, hashed names in production

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
projects/js-packages/webpack-config/src/webpack/css-rule.js Adds default modules configuration with auto-detection and development-friendly class names
projects/js-packages/webpack-config/changelog/add-local-name-for-css-module-classes-for-dev Documents the enhancement as a patch-level added feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +2
const isDevelopment = process.env.NODE_ENV !== 'production';

Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

The definition of isDevelopment here is inconsistent with the pattern used elsewhere in the webpack config package. In webpack.js and babel.js, the pattern is to define isProduction first, then derive isDevelopment from it. Consider changing this to match that pattern for consistency.

Suggested change
const isDevelopment = process.env.NODE_ENV !== 'production';
const isProduction = process.env.NODE_ENV === 'production';
const isDevelopment = !isProduction;

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't bother with this AI "fix".

@jp-launch-control
Copy link

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Looks reasonable, and no noteworthy changes in the build artifacts.

@manzoorwanijk manzoorwanijk merged commit 8e61677 into trunk Dec 16, 2025
99 of 100 checks passed
@manzoorwanijk manzoorwanijk deleted the add/local-name-for-css-module-classes-for-dev branch December 16, 2025 03:30
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants