Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Including custom CSS files from node_modules and CSS from gems #270

Closed
rozhok opened this issue Jun 2, 2023 · 1 comment
Closed

Including custom CSS files from node_modules and CSS from gems #270

rozhok opened this issue Jun 2, 2023 · 1 comment

Comments

@rozhok
Copy link

rozhok commented Jun 2, 2023

So let's say I want to add a gem, such as https://github.com/excid3/simple_calendar/, to my project. In the readme, it instructs me to include the gem's CSS file in my application.css:

*= require simple_calendar

If I only use tailwindcss-rails, it doesn't produce any results. The application.css won't be processed by the assets pipeline, and I won't get the desired results.

The same applies to any JS plugins that come with CSS files. There is currently no way to instruct tailwindcss-rails to include or concatenate these files into the resulting CSS.

I understand that I'm not the only user facing this issue. However, the suggested solution mentioned, for example, here, involves copy-pasting the styles directly into the application.css, which is obviously not the correct way to handle this.

I've asked this question on the forum and in the discussions but have not received any answers.

We need a standardized way to handle external CSS files. I can imagine there are many projects that want to use not only Tailwind and similar frameworks but also a rich ecosystem of gems and plugins.

@mariochavez
Copy link

Hi,

Let me share my experience here. First, this gem only works with CSS files, not SASS. If you need to work with SASS and files that are part of node_modules you will have better results with CSS bundling https://github.com/rails/cssbundling-rails.

If you still want to include files from other gems or node_files and use this gem, then you might want to enable Sprockets or Propshaft, the only drawback is that you will have two different stylesheets, one with TailwindCSS and a second for third-party CSS.

A third option, I apologize for my self-promotion, is to create a rake tasks that can dynamically include additional CSS from gems and node_modules while using this gem. Please visit this post to learn how to do it. https://mariochavez.io/desarrollo/2023/08/23/working-with-rails-engines-importmap-tailwindcss/

@rails rails locked and limited conversation to collaborators Jan 7, 2024
@flavorjones flavorjones converted this issue into discussion #309 Jan 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants