Comments (3)
How to patch
Note: I use pnpm here, but you can use npm or yarn.
1 - Install the following dev dependencies.
"devDependencies": {
"@softonus/prettier-plugin-duplicate-remover": "^1.0.1",
"@softonus/prettier-plugin-whitespace-remover": "^1.0.1",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "0.5.14" // <-- pin down this by removing the ^
}
2 - Run the patch command from within the root of your project.
pnpm patch prettier-plugin-tailwindcss -d tmp
3 - Open the right file to update
vim tmp/dist/index.mjs
4 - Find the list includes
prettier-plugin-sort-imports
5 - Manually add the whitespace-remover and duplicate-remover to the list
let e=[
"@ianvs/prettier-plugin-sort-imports",
"@trivago/prettier-plugin-sort-imports",
"@softonus/prettier-plugin-whitespace-remover", // <- this
"@softonus/prettier-plugin-duplicate-remover", // <- and this
"prettier-plugin-organize-imports",
"prettier-plugin-css-order",
"prettier-plugin-import-sort",
"prettier-plugin-jsdoc",
"prettier-plugin-organize-attributes",
"prettier-plugin-style-order",
"prettier-plugin-sort-imports"
]
6 - Extract the patch file to a local directory called .patches
pnpm patch-commit tmp --patches-dir .patches
7 - Install the new patch in package.json
pnpm install
8 - Verify the patch
Look at the package.json
file and you should see something like this:
"pnpm": {
"patchedDependencies": {
"[email protected]": ".patches/[email protected]"
}
9 - Clean up
rm -rf tmp
10 - Update your prettier config
plugins: [
require.resolve('@softonus/prettier-plugin-whitespace-remover'),
require.resolve('@softonus/prettier-plugin-duplicate-remover'),
require.resolve('prettier-plugin-tailwindcss'),
],
11 - Commit the .patches directory, and the changes to package.json and prettier config to git
git add .patches
git commit -am "Add patch for tailwindcss whitespace and duplicate removal"
git push
You are done!
Before:
![Screenshot 2024-05-20 at 6 19 24 AM](https://private-user-images.githubusercontent.com/407537/332029351-a892d613-89b6-47f5-9bcb-1d634d77cefd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6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MtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxM1QwNDAzMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zMzgwYTk0ODk0MzA5ZmVmNjczMjI1NTJhYThhMzcwNjFkMzFmMjBiNGVjZjRjYWZkODRhZDgwNTY5OWM0NTMxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.xyx4WSZUHggwifhmPHfxxg6GIT276JDlIKVhOcOWBF8)
from tailwindcss.
Heads up - If you add the patch, make sure you format the entire repository once without making any other changes. Raise a PR, and let others know that they might need to resolve conflicts.
This applies to large projects. Since whitespace and duplicate Tailwind CSS will be removed, it could create conflicts.
Hence, it is important to have an atomic patch creation and format of the entire repo in a single PR.
from tailwindcss.
The official fix has been merged in via tailwindlabs/prettier-plugin-tailwindcss#272. Version 0.6.0.
from tailwindcss.
Related Issues (20)
- Vulnerable Dependency - micromatch HOT 3
- v4: tailwind.default is not a function when running with Angular 17 and esbuild
- Classes generation error using symlink HOT 1
- [v3] Double quotes break arbitrary variants HOT 2
- `dark:` does not work with `@apply` in v3.4.3
- Create plugin: addBase does not work inside of matchComponents
- Col-end does not support negative values HOT 2
- For example: min-[1620px] is not workin, tailwind dont see this, but media xl, 2xl, md he is see)) (sorry for my english)
- Tailwind Play and Play CDN don't work with some custom utilities HOT 3
- Classes are prefixed when using `has-*` variants with arbitrary values HOT 2
- Unable to set default light mode in Vercel portfolio template HOT 2
- Unable to add borderRadius in tailwind.config.js. Inside theme.extend property HOT 1
- Class detection in Ruby Template files
- Small bug on negative 0.5 classes (like "-left-0.5") HOT 2
- error in an import (flattenColorPalette) HOT 1
- Compiler Memory Leak when (repeatedly) copying files on Win x64 HOT 3
- Generated css is not output from @tailwind directive HOT 1
- tailwind not compiling styles with nextjs custom servers
- Arbitrary value for `anchor-name` outputs as custom variable instead of identifier value HOT 3
- backdrop-blur-none still applies a blur HOT 2
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 tailwindcss.