Tailwind config file is rewritten
Im using nextjs 13 with the app router and when I init shadcn it breaks some of my styles.
ShadCN is basically overriding your previous talwind configurations and I need to configurate tailwind again.
The tailwind.config.js should be updated, not rewritten
+1
I was so surprised the first time it happened. I had to undo the change and manually copy over the edits. I agree it should update the config and not overwrite what's already there.
@yangenmanuel Yes, or what one can do it init the shadcn at the first step just after creating next app and then you can include more tailwind config in it so that it doesn't override.
This was pretty annoying, I had written a tailwind config and not commited yet, then shadcn overwrote the file without even displaying a warning.
@yangenmanuel Yes, or what one can do it init the shadcn at the first step just after creating next app and then you can include more tailwind config in it so that it doesn't override.
Thats's an option but, what if in an existing project i want to add shadcn? At least you have to receive a feedback from the CLI saying something like "creating new tailwind config file" or "your tailwind configs will be overrided". The ideal should be an update on the existing file
Agree, this just happened to me. Luckily I was able to revert with Git.
Just lost my tailwind config 😭... Please fix this guys, a warning will be sufficient for now!
It overwrites both tailwind.config.js and global.css.
How to deal with this issue?
any updates here???
How to deal with this issue?
There's a temporary solution, as follows; pass different path to each file which may get overwritten, and then merge all the files manually with changing paths in components.json
a warning would've been nice
Yup, incredibly annoying tbh
This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.
Is this fixed?
I don't think so because I just had the same issue yesterday
Why were they built in this way? Very annoying😡😡😡
I'm working on this. No more overriding files.
This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.
Noticing this is still an issue, is this still being worked on?
I'm experiencing the same problem. In my case, init caused not only my tailwind configuration to be overwritten, but also my entire lib/utils.ts file without even warning me. I don't understand why the existence of such files is not checked first. This is terrible.
@dusanbrankov Are you using shadcn-ui or shadcn? Note: the new cli is shadcn and does not overwrite.
@shadcn I followed the instructions in the docs, I used npx shadcn@latest init and the same command to add components. I didn't use shadcn-ui, just checked my shell history in a new session to be sure. The path to the affected file in my case is src/lib/utils.ts.
The init command has created the following aliases inside components.json:
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
And these are my aliases from tsconfig.json that existed before, maybe this has something to do with it:
"paths": {
"@/icons/*": ["./src/components/ui/icons/*"],
"@/components/*": ["./src/components/*"],
"@/*": ["./src/*"]
}
Yeah. This looks right. It reads your tsconfig paths and updates components.json. Is it still overwriting files? (It should only update)
It overwrote the existing utils.ts file and replaced it with the cn() function, I'm not sure if it adds the function on initialization or when adding the first component. I just added another component with the same add command as before, nothing was overwritten this time, probably because the function already exists. So it seems that it only creates/overwrites the utils.ts file if the function doesn't exist yet.
Edit: My assumption was wrong, I removed the cn() function from utils.ts and added another component, it just adds the component without touching utils.ts, so the init command must have caused the overwrite. So I am not sure what exactly you mean by "is it still overwriting files"?
This issue is still occuring in the new shadcn cli. I'm using the fluid-tailwind package and I'm bringing their fontSize and screens theme objects into the theme in my tailwind.config. I've had this config setup for a while but today when I went to install the accordion my config was overwritten and these values where removed. Thankfully the imports remained and eslint flagged the unused vars so it was an easy catch but this will be a pain point if it continues to occur with more component installations.
@shadcn ,The issue still persists i cannot use my own conifg inside tailwind-config.ts ,it keeps overwriting ,npx shadcn@latest init command used for installation