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

For Rails 7, download tailwindcss-stimulus-components to vendor/javascript #153

Closed
justinko opened this issue Apr 10, 2022 · 1 comment
Closed

Comments

@justinko
Copy link

This is just to help others that might be wondering why they're missing styles after upgrading to Rails 7.

If you're using tailwindcss-rails with Rails 7, you need to specify how to find the CSS classes tailwindcss-stimulus-components uses (e.g. the ones in modal).

Here's what you need to do:

  1. Download to vendor/javascript so tailwindcss-rails can find the CSS classes: bin/importmap pin tailwindcss-stimulus-components --download
  2. Add vendor/javascript to your tailwind config:
module.exports = {
  content: [
    './app/helpers/**/*.rb',
    './app/javascript/**/*.js',
    './app/views/**/*',
    './app/lib/form_builder.rb',
    './vendor/javascript/tailwindcss-stimulus-components.js'
  ],
}

That's it! All the tailwind classes that this library uses will now be included in your Rails app.

@Petercopter
Copy link

I was poking around for a solution as well, it seems reasonable to use safelisting as well:

https://stackoverflow.com/questions/70597881/exclude-a-class-being-tree-shaken-by-tailwind

@excid3 excid3 closed this as completed Aug 3, 2023
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

3 participants