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

problem with global classes #35

Closed
dartess opened this issue Jan 17, 2024 · 5 comments
Closed

problem with global classes #35

dartess opened this issue Jan 17, 2024 · 5 comments

Comments

@dartess
Copy link

dartess commented Jan 17, 2024

Hey!

First thank you for this package!

I got a problem: in addition to CSS modules, I use a small number of global classes. Specifically, the class of the current locale. These are short two letter classes. Minified classes began to overlap with them quite quickly.

Do you have any options to solve this problem?

I see two potential options:

  1. provide the options to set a disallowlist of minified classes (rude and dangerous).

  2. provide the option to set a prefix and/or postfix, for example, so that all minified classes begin with _.

@vordgi
Copy link
Owner

vordgi commented Jan 17, 2024

Hello! Thanks for the task and suggestions, good point. I'll work with adding the reservedNames option.

@dartess
Copy link
Author

dartess commented Jan 17, 2024

I'm not sure this would be the best solution.

Let's say I can make a list of such classes and pre-add them to "reservedNames". However, besides me, there may be other developers who are not know about using this tool. For example, in my case, an example would be adding a new locale.

Such classes can also be added by external libraries, then the list of classes will generally be uncontrollable

Therefore, the option of adding a prefix will probably be preferable for me personally. I'd rather get less savings, but more stability.

@dartess
Copy link
Author

dartess commented Jan 17, 2024

One more thought:

It seems you are fit in both before and after css modules loader.

I'm not closely familiar with the webpack algorithms, but do you have the opportunity to analyze the use of :global selectors before minified names are formed? If this happens by default, some cases will be closed without additional setup.

@vordgi
Copy link
Owner

vordgi commented Jan 17, 2024

So many useful points and ideas, thank you again! Yeap, I will add the ability to add a prefix, apparently for some situations this is mandatory. Then, after these updates, I will see if it's possible to analyze global classes

@vordgi
Copy link
Owner

vordgi commented Jan 20, 2024

So! I was looking for a way to analyze global classes and... No, this is not possible in the current package logic.

The problem is that the package should check all files for the presence of global classes and only then start generating classes, but now the package does this on time for each file.

In any case, I hope that current features will be enough for most cases.

Thanks for the help!

@vordgi vordgi closed this as completed Jan 20, 2024
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