Comments (12)
@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 0.1.9-beta.1
?
For some cases, I have done processing:
className={style.className}
=>className='flex ...'
className={clsx(style.className1, style.className2)}
=>className={clsx('flex ...', ...)}
className={`${style.className1} ${style.className2}`}
=>className={`flex ...`}
className={clsx({ [style.className]: true })}
=>className={clsx({ ['flex ...']: true })}
Thanks.
from css-modules-to-tailwind.
@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.
from css-modules-to-tailwind.
Oh, I see. I read the file directly, the processed file has some newlines, file content converted to boolean
is true
, but it should be false
... π
![image](https://private-user-images.githubusercontent.com/19943129/239703580-76da517b-68c7-4936-a0ce-07475e5fdce8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDQzMzc1MDksIm5iZiI6MTcwNDMzNzIwOSwicGF0aCI6Ii8xOTk0MzEyOS8yMzk3MDM1ODAtNzZkYTUxN2ItNjhjNy00OTM2LWEwY2UtMDc0NzVlNWZkY2U4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAxMDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMTA0VDAzMDAwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQzM2ZmYjFjZDIzMDc5NGExMWNlOTRlZjgyODI2NWU1OTlkZGEwOWUwMzBhOGYzMDhkNDcyMWFhOWIzMzBmMmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.DOj_z3hcv7Z2mv-r_3FMoa-nWV6CF65w7XQOT0O-O24)
[email protected]
will delete the import specifier, and css files are also removed.
from css-modules-to-tailwind.
Version 0.1.9, released.
from css-modules-to-tailwind.
Thank you for the quick response and implementation (again)!
This works really nicely.
There is one more case to solve forβwhen the *.module.css
file is empty, it should be removed, and the import
of that file in the jsx
should also be removed. That way a project wouldn't have empty files or unused imports.
I understand if this is somewhat out of scope, but it would be a nice to have.
from css-modules-to-tailwind.
Hi, you can try version 0.1.9-beta.2
, because the import specifier is removed, the corresponding style member expressions also needs to be modified, for example:
/** 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~
from css-modules-to-tailwind.
I tried 0.1.9-beta.2
and I got the same result as beta.1
where the *.css.module
file is empty after the transform, but the import * from styles
import specifier is still in the file, so I'm not seeing any change in the output. Is there any other config to tell it to remove the specifier? Maybe if it was opt + a warning when using it instead of default behavior it would be OK that it is a dangerous operation?
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!
from css-modules-to-tailwind.
I am seeing the same result for 0.1.9-beta.4
.
Thanks for your suggestion, if no one uses it, I don't bother to optimize it.
You're welcome, thanks for implementing it so quickly!
from css-modules-to-tailwind.
I need code samples that can reproduce the problem, such as https://codesandbox.io/
from css-modules-to-tailwind.
I am trying to get together a minimal reproduction for you, but it is a bit difficult since we are using your library via npx
as a step in our CLI, and right before we run your library we run postcss
on our css variables to transform those into something your library can read first (another feature that would be awesome if it was built in to your library π ). I can outline the steps to setup our CLI locally but I worry it's a bit of work. I will try to get something less involved on Monday, but if you'd like I'll outline the steps I am using below. Please do not feel pressured to use these steps as I understand it is quite involved.
- Clone the following monorepo: [email protected]:pantheon-systems/decoupled-kit-js.git
- in the root of the monorepo,
pnpm i
you may need pnpm8.1.0
You may see errors of things failing to build, you can ignore those. Make surepnpm build:cli
passes tho. - On this line, change update the
css-modules-to-tailwind
command to the@0.1.9-beta.4
https://github.com/pantheon-systems/decoupled-kit-js/blob/canary/packages/create-pantheon-decoupled-kit/src/actions/convertCSSModules.ts#L45 - The, to call the CLI the easiest thing to do is to set up a watch script. I will copy one below that you can use. You may want to change the
outDir
to something else. the important part that will run the convert action istailwindcss: true
- in the terminal, run
pnpm watch:cli
. You should see the CLI generate a new app then try to convert the CSS modules. The last linting step will fail due tostyles
being an unused var in thesrc/pages/404.jsx
file. You can see the404.module.css
is empty
Here is the `watch.ts` file you will put at the root of `decoupled-kit-js/packages/create-pantheon-decoupled-kit`
import type { ParsedArgs } from 'minimist';
import path from 'path';
export const watchOptions: ParsedArgs = {
_: ['gatsby-wp'],
outDir: path.resolve(process.env.HOME as string, 'test-cli', 'css-mods-repro'),
appName: 'css-modules-to-tw-repro',
cmsEndpoint: 'https://any',
noInstall: false,
// force overwrite of the target directory.
// WARNING: this option could overwrite uncommitted work.
// Choose an empty outDir for best results with this options.
force: true,
// silent: true,
// number of milliseconds to debounce file system watching
tailwindcss: true,
debounce: 5000,
};
from css-modules-to-tailwind.
Nice, LGTM! Thanks again for the quick turnaround on this, it is very much appreciated!
from css-modules-to-tailwind.
Thanks again, just ran another test and it works great.
from css-modules-to-tailwind.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-modules-to-tailwind.