Skip to content

tailwindcss-rails plus propshaft is not working as expected #214

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
etagwerker opened this issue Oct 26, 2022 · 1 comment
Closed

tailwindcss-rails plus propshaft is not working as expected #214

etagwerker opened this issue Oct 26, 2022 · 1 comment

Comments

@etagwerker
Copy link

Hi there,

I'm trying to use tailwindcss-rails with propshaft in my Rails 7 app and I'm having a weird issue where the css changes are not showing up without a manual call to rake assets:precompile

Here is my tailwind configuration:

const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
  content: [
    './public/*.html',
    './app/helpers/**/*.rb',
    './app/javascript/**/*.js',
    './app/views/**/*.{erb,haml,html,slim}'
  ],
  theme: {
    extend: {
      fontFamily: {
        sans: ['Inter var', ...defaultTheme.fontFamily.sans],
      },
    },
  },
  plugins: [
    require('@tailwindcss/forms'),
    require('@tailwindcss/aspect-ratio'),
    require('@tailwindcss/typography'),
  ]
}

Here is my config/initializers/assets.rb:

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

I see that the installation task has some glue for sprockets:

if (sprockets_manifest_path = Rails.root.join("app/assets/config/manifest.js")).exist?
append_to_file sprockets_manifest_path, %(//= link_tree ../builds\n)
end

The watch command seems to be working fine. I change something in my application.tailwind.css and I see it updated in the app/assets/builds files and I see this in the console:

15:16:34 css.1  |
15:16:34 css.1  | Rebuilding...
15:16:34 css.1  |
15:16:34 css.1  | Done in 307ms.

Am I missing some glue code for propshaft to pick up the changes from app/assets/builds?

Here is the repository where you can reproduce this issue: https://github.com/fastruby/librarian

At this point the only workaround I have to see the changes to my css is to stop the application, run rake assets:precompile, and then start the app again.

Please let me know.

Thanks!

@etagwerker
Copy link
Author

It turns out that the problem was that I had some auto-generated files in app/assets/builds and in public/assets that were throwing propshat off. After removing all those files and restarting the application, it started working.

Sorry for the noise. Leaving this here in case it helps anyone in the future.

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

1 participant