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

Resolve tailwind.config.cjs by default in ESM projects. #567

Closed
scott-lc opened this issue Nov 1, 2021 · 2 comments · Fixed by #668
Closed

Resolve tailwind.config.cjs by default in ESM projects. #567

scott-lc opened this issue Nov 1, 2021 · 2 comments · Fixed by #668
Labels
feature request New feature request

Comments

@scott-lc
Copy link

scott-lc commented Nov 1, 2021

In an ESM project (that is type='module'), CommonJS/CJS like configuration files are typically written with a CJS extension:

tailwind.config.cjs

When using Twin in an ESM project, any existing tailwind.config.cjs configuration file is silently ignored as the code only attempts to resolve a tailwind.config.js file as seen here.

It would be nice if Twin was a little friendlier to ESM projects and attempted to load the a Tailwind config file with a CJS extension instead of silently ignoring it. Tailwind added support for CJS configuration files here.

The workaround, of course, is to simply specify the path to the CJS configuration file in the macro configuration:

  "babelMacros": {
    "twin": {
      "config": "tailwind.config.cjs",
      "preset": "styled-components"
    }
  }

This works perfectly, but sadly took me a long time to debug.

@ben-rogerson
Copy link
Owner

Hey thanks for posting this request.
This sounds like a good feature to me - twin will just need another check added here.
Feel free to help out with a PR if you'd like!

@ben-rogerson
Copy link
Owner

This feature will be in the next release 🌮 🎉

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

Successfully merging a pull request may close this issue.

2 participants