Skip to content

yarn rw setup tailwind fails if packages already installed or if imports exist in index.css #1301

@thedavidprice

Description

@thedavidprice

Continued from #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:

  1. Successfully run yarn rw setup tailwind
  2. Remove the postcss config file rm web/config/postcss.config.js
  3. Remove the tailwind config file rm web/tailwind.config.js
  4. 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions