Skip to content

fix: configure Vite CSS modules to match CRA class naming convention#930

Open
Dhanushree-Microsoft wants to merge 1 commit into
devfrom
fix/vite-css-modules
Open

fix: configure Vite CSS modules to match CRA class naming convention#930
Dhanushree-Microsoft wants to merge 1 commit into
devfrom
fix/vite-css-modules

Conversation

@Dhanushree-Microsoft
Copy link
Copy Markdown
Contributor

Problem

The Vite migration (part of PR #922) changed how CSS module class names are generated.

  • CRA (webpack) generates: \ChatHistoryListItemCell_chatTitle__areVC\ (format: [name]_[local]__[hash])
  • Vite default generates: _chatTitle_1a2b3c\ (format: _[local]_[hash])

The e2e test locator //div[contains(@Class, 'ChatHistoryListItemCell_chatTitle')]\ expects the CRA format with the filename prefix. With Vite's default naming, the locator can't find the element → test fails with:

\
AssertionError: Chat history name was not visible on the page within the expected time.
\\

Fix

Added \css.modules.generateScopedName\ to \�ite.config.ts\ to produce CRA-compatible class names:

\\ s
css: {
modules: {
generateScopedName: '[name]_[local]__[hash:base64:5]',
},
},
\\

Related

The Vite migration changed CSS module class name generation from CRA's
format ([name]_[local]__[hash]) to Vite's default format (_[local]_[hash]).
This broke e2e test locators that rely on class names containing the
component filename prefix (e.g., 'ChatHistoryListItemCell_chatTitle').

Add generateScopedName config to produce CRA-compatible class names,
ensuring existing e2e tests continue to work without modification.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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 restores Create React App–style CSS Module class name generation in the Vite-based frontend build so existing e2e selectors (that depend on the filename-prefixed class name) continue to work after the Vite migration.

Changes:

  • Configure css.modules.generateScopedName in Vite to emit [name]_[local]__[hash:base64:5] class names (CRA-compatible).
  • Align generated CSS module class naming with existing e2e test expectations to unblock pipeline failures.

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

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