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

Adds support for tailwind.config.cjs files #3181

Merged
merged 4 commits into from
Feb 7, 2021

Conversation

natemoo-re
Copy link
Contributor

@natemoo-re natemoo-re commented Dec 23, 2020

This PR adds default resolution and npx tailwind init support for tailwind.config.cjs files.

Currently, users who rely on Node ESM with "type": "module" (officially supported since [email protected]) must manually require and pass their Tailwind config file to Tailwind.

Implementing true esm-compliant config files would likely be a large undertaking (requested in #2284), but this PR is a fairly simple stop-gap. With these changes, ESM users will now have the exact same DX as CJS users.

Changes

  • Tailwind will automatically resolve and use a tailwind.config.cjs file if one exists
  • npx tailwind init will automatically generate a tailwind.config.cjs file when run inside of a project with "type": "module" in package.json
  • npx tailwind init -p will generate a tailwind.config.cjs file and a postcss.config.cjs file when run inside of a project with "type": "module" in package.json

@codecov-io
Copy link

codecov-io commented Dec 23, 2020

Codecov Report

Merging #3181 (80b393b) into master (e5bb0d3) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3181      +/-   ##
==========================================
+ Coverage   93.28%   93.33%   +0.05%     
==========================================
  Files         178      178              
  Lines        1831     1846      +15     
  Branches      323      328       +5     
==========================================
+ Hits         1708     1723      +15     
  Misses        105      105              
  Partials       18       18              
Impacted Files Coverage Δ
src/cli/commands/init.js 96.42% <100.00%> (+0.59%) ⬆️
src/cli/utils.js 84.78% <100.00%> (+2.28%) ⬆️
src/constants.js 100.00% <100.00%> (ø)
src/index.js 90.62% <100.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5bb0d3...80b393b. Read the comment docs.

@natemoo-re
Copy link
Contributor Author

This will also likely need a small note added to the docs and support in tailwindcss-intellisense

src/constants.js Outdated Show resolved Hide resolved
src/cli/utils.js Show resolved Hide resolved
@adamwathan adamwathan merged commit e86b586 into tailwindlabs:master Feb 7, 2021
@adamwathan
Copy link
Member

Thanks!

@natemoo-re natemoo-re deleted the support-cjs branch February 7, 2021 23:41
This was referenced Mar 15, 2021
This was referenced Mar 18, 2021
adamwathan pushed a commit that referenced this pull request May 7, 2021
* feat: automatically init and resolve tailwind.config.cjs files

* test: add tests for default tailwind.config.cjs resolution

* fix `cjsConfigFile` constant

* Fix JSDoc type of isModule
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

Successfully merging this pull request may close these issues.

4 participants