feat: allow modules.getLocalIdent
to return a falsy value
#963
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains a:
Motivation / Use-Case
With the suggested changes,
modules.getLocalIdent
would be allowed to return a falsy value, and in such case, the defaultgetLocalIdent
would be used instead.I am setting up a new project with
webpack
, I wish to apply the same chain of loaders on different kinds of.scss
files:main.scss
specified as anentry
in my configuration, meant to be used as global stylesheetApp.scss
SCSS modules which are imported from their matching component such asApp.js
This setup works very well for me, except that
main.scss
classnames necessarily go throughcss-loader
withmodules
enabled and usinglocalIdentName
.See the following example:
While browsing issues, looking for a way to not use
localIdentName
for mymain.scss
file, I stumbled upon #862.getLocalIdent: () => foo && 'bar'
seemed to be a great fit for my use-case.The behavior introduced in #865 wouldn't have worked for me though, here's what I did instinctively:
Note: my
main.scss
file resides inshared/assets/styles
.This way, my SCSS modules will use
localIdentName
andmain.scss
will uselocalName
.Breaking Changes
None
Additional Info
Thank you for this great package :)
I'm willing to make the final changes if this looks reasonable, thank you in advance for any response.