Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #9134
Closed
Open
Issue created Jun 10, 2020 by Administrator@rootContributor

Making CSS class name unique across projects to prevent name collision when hosting multiple project in one document

Created by: tkforce

Is your proposal related to a problem?

Currently we're trying to incorporated multiple CRA applications into one page. The idea is to dynamically fetch the html of multiple react applications hosted under the same domain and append onto a single html document.

The problem is when using css module, the current css class name generation process only consider filename or folder name which can only ensure the uniqueness within that project. But If we have multiple project who happens to have the a same css class name in the same relative path (eg. src/app/app.module.css), same class name MyFolder_MyClass__[hash] will be generated, and If we put all those css from different project onto the same html document, there will be name collision issue.

Describe the solution you'd like

I'd like to request a way to make css class name unique not only within project but also across projects.

Describe alternatives you've considered

  • One possible solution is to alter the hash generation function discussed in this thread, unfortunately this can't be done in CRA unless we eject or rewire.
  • An alternative is to add project name as part of the input of the hash generation process, similar to what you guys've done to fix webpackJsonp naming conflicting issue, so in this case possibly adding project name into hash generation process in packages/react-dev-utils/getCSSModuleLocalIdent.js?

Additional context

(Write your answer here.)

Assignee
Assign to
Time tracking