Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getLocalIdent pass selector type #1540

Closed
koga73 opened this issue Sep 26, 2023 · 3 comments
Closed

getLocalIdent pass selector type #1540

koga73 opened this issue Sep 26, 2023 · 3 comments

Comments

@koga73
Copy link
Contributor

koga73 commented Sep 26, 2023

Feature Proposal

I propose that we update the getLocalIdent parameters to pass whether the localName selector is an id or class.

Currently you can pass a custom function for getLocalIdent however there is no way to determine whether the localName parameter is an id or class.

Upon examining the Utils.js file it utilizes "postcss-modules-scope" package and passes a "generateScopedName" function. This function passes (exportName, resourceFile, rawCss) parameters. Currently css-loader only makes use of the exportName parameter. Using the rawCss parameter we can determine if the exportName is an id or class and pass this info to the getLocalIdent function.

Feature Use Case

I would like the ability to only transform class names and not transform id. This is because keeping the original id is useful for anchoring (href="#section1") as well as code that rely on finding elements by id (automated tests, analytics, vanilla js, etc).

Please paste the results of npx webpack-cli info here, and mention other relevant info

  System:
    OS: Windows 10 10.0.19042
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 50.14 GB / 63.90 GB
  Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 116.0.5845.188
    Edge: Spartan (44.19041.423.0), Chromium (117.0.2045.41)
    Internet Explorer: 11.0.19041.1
  Packages:
    babel-loader: 8.2.2 => 8.2.2
    copy-webpack-plugin: 9.0.1 => 9.0.1
    css-loader: 5.0.1 => 5.0.1
    dotenv-webpack: 6.0.0 => 6.0.0
    html-webpack-plugin: 5.5.3 => 5.5.3
    sass-loader: 13.2.2 => 13.2.2
    string-replace-loader: 3.1.0 => 3.1.0
    webpack: 5.88.1 => 5.88.1
    webpack-cli: 5.1.4 => 5.1.4
    webpack-dev-server: 4.15.1 => 4.15.1
@alexander-akait
Copy link
Member

PR welcome

@koga73
Copy link
Contributor Author

koga73 commented Dec 21, 2023

PR: #1556
Thank you!

@alexander-akait
Copy link
Member

Fixed #1556

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

No branches or pull requests

2 participants