Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Add a clearer error message regarding Tailwind JSON #77

Open
joshuapease opened this issue Jan 10, 2024 · 0 comments
Open

Comments

@joshuapease
Copy link
Contributor

joshuapease commented Jan 10, 2024

Bug that prompted this ticket

Overview:

Craft projects can optionally import a JSON encoded version of a project's TW config.

Most often, we use these TW config values in Twig:

  • Use Tailwind's screens key/value pairs in a component so we can use values like sm, md, etc to get a configured media query. MW's image macro uses it so that srcset/sizes code is kept in sync with Tailwind's breakpoints (it also saves writing out full media queries).
  • Automatically displaying config values like colors & sizes in our parts kit (see MW again).

Decision points
We need to decide if we want a hard error on every page or some other kind of warning.

I think an exception is still necessary, but a clearer error message that explains what the file is for and why it's not there would be a useful improvement.

If template code depends on a JSON file being there, it probably makes sense to know right away rather than have unexpected behavior, or exceptions on only a handful of pages that might make calls to TW.

One frustrating thing about the current implementation is that it always looks for a JSON file and throws even if you aren't using it in your config.

We may want to make this an opt-in feature. However, that would probably be a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant