Skip to content

Missing documentation about tailwind.config.js customization #25

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

Closed
rubenjimenez opened this issue Jan 25, 2021 · 5 comments
Closed

Missing documentation about tailwind.config.js customization #25

rubenjimenez opened this issue Jan 25, 2021 · 5 comments

Comments

@rubenjimenez
Copy link

I was trying to customize Tailwind CSS via tailwind.config.js and looking for the proper way to do it I saw you wrote this:

When used with Webpacker, Tailwind CSS is installed as a postCSS processor. Refer to the TailwindCSS documentation to customize your tailwind.config.js file.

I followed all the steps in the Tailwind CSS documentation but I didn't get it to work so I made a little research and I found there're some additional steps to accomplish before it works with Rails.

Once you've installed the gem:

  • npx tailwindcss init
  • Move the recently created tailwind.config.js file somewhere inside your ./app/javascript folder in order the file to be packed for Rails (important).
  • Modify postcss.config.js to tell Webpacker where is the new file located: require('tailwindcss')('./app/javascript/tailwind.config.js'),
  • If you've copied the tailwind.config.js file from this repo, important to add the packages @tailwindcss/forms, @tailwindcss/aspect-ratio, @tailwindcss/typography to package.json and install.
  • Enjoy 🎉

The main problem I found was that Tailwind CSS documentation explains that the tailwind.config.js file is going to be searched (firstly) in the root of the project and currently in Rails this is definitely not going to happen.

I think this could be confusing and frustrating for people so maybe documentation should cover it as I guess customizing your Tailwind CSS boilerplate may be very common.

@PabloC
Copy link

PabloC commented Jan 27, 2021

Thank you for this. I was looking exactly this.

@jumph4x
Copy link

jumph4x commented Feb 4, 2021

Helpful!

@dhh
Copy link
Member

dhh commented Feb 4, 2021

Feel free to turn this into a PR that performs those steps 👍

@turgs
Copy link

turgs commented Feb 8, 2021

Thank for this. I'm curious about doing this with the Asset Pipeline, as I'm trying to avoid Webpack 🙏 I'd like to add a tailwind.config.js so I can force tailwind to prefix all classes with tw- so I can migrate bit-by-bit off other CSS frameworks without having them conflict.

@ferrisoxide
Copy link

ferrisoxide commented Feb 26, 2021

A possible addendum to this, though I'll preface and say I'm a bit clueless when it comes to webpacker, JS, et al.

I tried npx tailwindcss init but it kept throwing back the error Cannot find module 'autoprefixer' and wouldn't build the tailwind.config.js config file. Running npx tailwindcss-cli@latest init (per the Tailwind docs) did work though.

Yeah, ignore all that. I had an old version of node (~10.x) that was causing issues.

@dhh dhh closed this as completed Mar 31, 2021
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

6 participants