`yarn rw setup tailwind` fails if packages already installed or if imports exist in `index.css`
See original GitHub issueContinued from https://github.com/redwoodjs/redwood/issues/1223
Note: --force
option does not resolve the issue
Error output:
$ yarn rw setup tailwind
yarn run v1.22.4
$ C:\Users\tobbe\dev\redwood\rw20\node_modules\.bin\rw setup tailwind
√ Installing packages...
√ Configuring PostCSS...
× Initializing Tailwind CSS...
→ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Adding imports to index.css...
One more thing...
Command failed with exit code 1: yarn tailwindcss init
error Command "tailwindcss" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Done in 25.85s.
What’s happening is that either:
- the installed packages are already present …and/or…
- the tailwind imports already exist in
index.css
Note: if either of the config files exist, the error output makes sense and states the issue accurately. But the error given above is confusing and inaccurate.
Way to reproduce:
- Successfully run yarn rw setup tailwind
- Remove the postcss config file rm web/config/postcss.config.js
- Remove the tailwind config file rm web/tailwind.config.js
- Run yarn rw setup tailwind again
From @Tobbe
Now it might seem like a strange/contrived thing to do to remove the config files. But say you’re new, and screw something up with the config. You decide to delete the config files to try to start over again. It won’t work.
So I think yarn rw setup tailwind should re-create any missing config files (it does for the postcss config file already). And it could also have a --force option to recreate/override config files even if they already exist
How to improve
- In case of only packages already existing but no files or imports present, this command should work
- In case of imports already present, the command should fail but give accurate explanation
- Using
--force
should allow the command to run regardless of what is present
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:26 (26 by maintainers)
@thedavidprice, created PR https://github.com/redwoodjs/redwood/pull/1407. This is just to show you the work. Feel free to suggest any kind of changes. Would be more than happy to work on them.
Yes, makes sense @thedavidprice. Thank you.