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

Prevent duplicate tailwind css reference #412

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

rip747
Copy link

@rip747 rip747 commented Oct 2, 2024

On a newly generated 8.0.0.beta1 app it seems that the tailwind.css is referenced twice with the head of the generated layout

<link rel="stylesheet" href="/assets/tailwind-aaa98186.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/inter-font-1d90a608.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/application-8b441ae0.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/application.tailwind-bb2039bf.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/tailwind-aaa98186.css" data-turbo-track="reload" />

it seems that the injected stylesheet_link_tag is including the tailwind stylesheet

<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>

it is automatically included from the 'app' stylesheet call from the app/build directory

<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>

removing the tailwind reference

<%= stylesheet_link_tag "inter-font", "data-turbo-track": "reload" %>

prevents the duplicate in the generated layout

<link rel="stylesheet" href="/assets/inter-font-1d90a608.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/application-8b441ae0.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/application.tailwind-bb2039bf.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/tailwind-aaa98186.css" data-turbo-track="reload" />

Copy link

@brunoprietog brunoprietog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not the way to go, since :app will try to load all the css that must pass through the Tailwind transpiler in its pure state on each page, something that only works if you use only vanilla CSS. What we really need to do is to remove those 2 default lines in Rails 8 so that the only entry point is the Tailwind build.

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.

2 participants