-
Notifications
You must be signed in to change notification settings - Fork 5
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
Remove unused class from jsx if the class is removed from the css module file #3
Comments
@CobyPear I wanted to solve this problem before but I was too lazy, and nobody asked me this question. I tried to fix it, can you try the version For some cases, I have done processing:
Thanks. |
Thank you for the quick response and implementation (again)! This works really nicely. There is one more case to solve for–when the I understand if this is somewhat out of scope, but it would be a nice to have. |
Hi, you can try version /** index.module.css */
.test {
display: flex;
} import style from 'index.module.css';
const Component = () => (
<div className={style.test}>
<div className={style.invalid}></div>
</div>
); After removed: const Component = () => (
<div className='flex'>
<div className={'invalid-class'}></div>
</div>
); Deleting import specifier is a dangerous operation, please make sure your code run successfully, thanks~ |
I tried Also, please let me know if you accept sponsorships/donations through any platform as I am trying to get some $$ to you on behalf of my employer for all this work, thank you! |
@CobyPear Can you try version 0.1.9-beta.4, I found a bug with an unhandled promise rejection in the code. Thanks for your suggestion, if no one uses it, I don't bother to optimize it. |
I am seeing the same result for
You're welcome, thanks for implementing it so quickly! |
I need code samples that can reproduce the problem, such as https://codesandbox.io/ |
I am trying to get together a minimal reproduction for you, but it is a bit difficult since we are using your library via
|
Nice, LGTM! Thanks again for the quick turnaround on this, it is very much appreciated! |
Version 0.1.9, released. |
Thanks again, just ran another test and it works great. |
Hi, I have another request in order for this library to work a bit better for Gatsby related projects 😄.
Problem
Gatsby will throw errors if you import a style that does not exist in the css module file at build time.
For example, the jsx is left like so after the conversion:
${styles.navItemLink} text-blue-300 no-underline
But
.navItemLink
is removed from the css module file because all styles have been transformed to tailwindcss classes.Gatsby will attempt to import
.navItemLink
from the file and throw an error because it is no longer present.Proposed Solution
Remove the
styles.className
from theclassName={}
if the class no longer exists in the module.The text was updated successfully, but these errors were encountered: