Library converts HTML CSS into tailwind based UI
[email protected]:Jakhotiya/tailwindify.git
cd tailwindify;
npm install;
Once the codebase is ready, we need to generate a master tailwind css file. This tailwind output css file is unpurged version. tailwind.config.js in this repository shows how to avoid purging anything by using safelist. This file is used to lookup utility class for a given css rule
create two files named input.css and output.css in project root
Roughly your input.css will have following contents
@tailwind base;
@tailwind components;
@tailwind utilities
when you run following command output.css should be generated.
npx tailwindcss -i ./src/input.css -o ./dist/output.css
Once you have a tailwind file ready with filename output.css
run following to generate one time tailwinddb using following command
node generate-reverse-class-index.js
A big json file should be generated in data directory.
Once this is done. Go ahead and run tests
If your source css contains property values that are non-standard from tailwind perspective, we will need to tell our program how to handle this situation. Consider following source css
/** The whole css block is known as Rule
* Every property specification inside { } block is known as declaration.
*/
.foo {
margin:13px;
color:red;
font-size:17px;
border : solid 1px green
}
Now if red and green colors are not mentioned in your tailwind config, we will have to provide a map/function for tailwindify to be able to migrate such rules.
This is the file where the logic kicks in. This file takes html and css as input. It returns the target html.
This file's only responsibility is to process css rule given. It returns tailwind classes for declarations it could process. it also returns declarations it could not process.
What if old class from old framework matches a tailwind class. This would introduce a bug hence removing old classes is important.