Skip to content

Assets are never re-compiled #7

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
sudhirj opened this issue Jan 15, 2021 · 8 comments
Closed

Assets are never re-compiled #7

sudhirj opened this issue Jan 15, 2021 · 8 comments

Comments

@sudhirj
Copy link

sudhirj commented Jan 15, 2021

There seems to be a caching issue happening—assets:precompile does nothing even if new classes are used and purging needs to happen again. I have to run assets:clobber first to force a full re-compile.

@sudhirj
Copy link
Author

sudhirj commented Jan 15, 2021

Just so I understand, based on https://github.com/rails/tailwindcss-rails/blob/main/lib/tailwindcss/engine.rb

The tailwind file is registered, but that file is never going to change, right? I assume Sprockets will never trigger a new compile if the source files don't change... is there a way to tell Sprockets that the compressor is going to produce different output this time, so it should re-compile even if the inputs are the same?

@dhh
Copy link
Member

dhh commented Jan 16, 2021

Yeah, we should document this limitation at the moment. Feel free to look into whether there's a way to tell sprockets that the compressor thinks its time for a rebundle, even if the source didn't change.

@sudhirj
Copy link
Author

sudhirj commented Jan 18, 2021

Sprockets has a depend_on directive that would work, if we pass in the full list of all the files that have been considered for class lookups. Will try to raise a PR using this method, unless someone has a better way to handle this.

@dhh
Copy link
Member

dhh commented Jan 18, 2021

Oh, that's a great idea. Let's give that a try 👍

@sudhirj
Copy link
Author

sudhirj commented Jan 18, 2021

PR #12 raised, uses the dependencies key in the output and passes the digest URI for all the files that we extract classnames from.

@dhh
Copy link
Member

dhh commented Jan 18, 2021

Documented need for clobber in a2abc42.

@sudhirj
Copy link
Author

sudhirj commented Jan 18, 2021

The way I'm working around this now is to disable the asset cache using the instructions in https://guides.rubyonrails.org/v6.1/asset_pipeline.html#assets-cache-store

I'd suggest documenting this as the recommended approach, it's the only way I can see that handles all the edge cases.

It also works to automatically fix the Heroku build even if it was deployed without switching off the cache.

@dhh
Copy link
Member

dhh commented Jan 18, 2021

Made this the default in 2097fc4.

@dhh dhh closed this as completed Jan 18, 2021
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 a pull request may close this issue.

2 participants