Skip to content

Tailwindcss ignores classes from node_modules #232

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
Napishite opened this issue Dec 10, 2022 · 1 comment
Closed

Tailwindcss ignores classes from node_modules #232

Napishite opened this issue Dec 10, 2022 · 1 comment

Comments

@Napishite
Copy link

Hi!

I found case when Tailwindcss doesn't build overriden classes from node module on assets:precompile during deploy.

TL;DR:

If you have in your Gemfile tailwindcss-rails before jsbundling-rails tailwind will not scan project dependencies for styles in production environment during assets:precompile. If jsbundling-rails goes first it works well.

Possible solution:

This happen because they both enchasing assets:precompile task and tailwindcss-rails run tailwindcss:build before javascript dependencies will be installed by javascript:build and tailwind just have nothing to scan.

Maybe it could be solved by mounting tailwindcss:build to javascript:build if it defined?

# build.rake:

if Rake::Task.task_defined?("javascript:build")
  Rake::Task["javascript:build"].enhance(["tailwindcss:build"])
else
  Rake::Task["assets:precompile"].enhance(["tailwindcss:build"])
end

More details about my case:

In my app I use Tailwindcss-rails, jsbundling-rails, with esbuild and fullcalendar.

I wanted to override some classes and added to my application.tailwind.css somehting like this:

    .fc .fc-daygrid-day.fc-day-today {
        background-color: rgba(107,33,168,0.15);
    }

And also set path fullcalendar in my tailwind.config.js:

  content: [
    ...
    "./node_modules/@fullcalendar/**/*.js"
  ],

Overriden classes worked perfectly in dev environment, because I aways have node_modules installed at the moment of running tailwindcss:build. But in production (in my case staging) environment when I run assets:precompile tailwindcss generated all styles excepting related to fullcalendar.

@Napishite Napishite changed the title Tailwind ignores classes from node_modules Tailwindcss ignores classes from node_modules Dec 10, 2022
@flavorjones
Copy link
Member

Apologies for not responding before now. I'd welcome a PR that either documents this rake task workaround or updates the rake tasks for this use case.

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

2 participants