-
Notifications
You must be signed in to change notification settings - Fork 97
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
change is not detected in @import css file #90
Comments
I think the issue is with the digested that means css_asset_urls compiler never get's triggered when change happens in one way how I can enforce this is to place some random css to application.css e.g.
|
I think the root cause is in this comment "Restarting of rails server don't help". If restarting the server helped, than that would mean the error was that Propshaft was not noticing the file being changed and reloading it. Since restarting the server did not work it means that the file that Propshaft sees as Looking at your assets reveal, I see both Instead of |
I've double checked that and seems no
I actually tried this with multiple other files (not committed in that dummy project ) and seem to be same exact behavior I'm digging into this issue, playing around with source, as I want to contribute my 5-cents to Propshaft. I'll update this ticket as soon as I have something worth your time (PR maybe or whatever). Just wanted to check if this a known issue (looks like it's not) |
I would have to write really long comment to fully explain the reason for the issue in detail. Therefore I've created screencast to better explain it -> https://youtu.be/SoT9quSjous it's worth watching it but in short there are 2 problems:
problem 1 - browser caches application.cssbrowser keeps in cache of given application.css content forever. This causes issue if some file imported inside it has changed. e.g. if you replace bootstrap.css with newer bootstrap.css but name is the same => browser will never detect bootstrap.css if content of application.css match one of the cached versions this is (probably) problem when app uses Dynamic resolver. I'm not sure. draft of a PR with proposed fix equivalent#1 (in brief: when asset digesting while using Dynamic resolver we also look at
problem 2 - application.css will not detect the imported my-custom.css has changedif one updates value in my-custom.css there is no way to tell browser to drop cache of current application.css. I was playing around with idea where by digesting my-custom.css I would dummy appfresh rails app with the problem to try for yourself: |
more I think about it more I realize the best way how to fix this is to avoid <head>
<title>Myapp</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "bootstrap.css", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag "my-custom.css", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
</head> The reason is that current implementation of assets.rb digests the If the gem guides developers to prefer adding multiple Quesiton is where would be the limit if developer has 50 vendor css files and 7 custom css files. Should developer add link tag for all 57 of them, or |
I had similar situation with bootstrap-icons.css which content is :
but was converted to
This was because I've copied file Once I've copied the second file to the Now once again this was not a problem of Propshaft but of a browser (Chrome) caching the file I think the best way how to solve it is just to recommend Developers to turn off caching while doing css changes. For example in Chrome developer can "Disable cache (while DevTools is open)"
|
...and I've just tested that by "Disable cache (while DevTools is open)" I've also solved the original issue with But it would be nice to point this out in advance in the README.md (it's a new gem, will be hard to spot this for a newcomers like me ) I've created -> #94 To sum it all up: This is not an issue:
BUT if are in development ENV doing lot of changes your browser by default caches everything, you will notice simmilar issues. Solution => ok to close this Issue from my side |
Sorry for the lack of feedback, things are a big rushed for me lately. I'll try to take a look next week. 🙇♂️ |
No worries, take your time ☕ . I've sorted it out for my usecase with the It's more to confirm if this is really the case and whether it's worth mentioning it to other developers in the Readme (e.g. #94) |
this will solve the issue #124 |
As I've mentioned in #124, changing headers is not enough. We need to properly calculate the digests to ensure parent digest changes when child digest changes. Since we are increasing our focus on a "no-build" pipeline, this issue needs to be fixed before we release v1, so I'll prioritize this. |
Hey @brenogazzola and @equivalent, I'm reading this issue and the PRs with the solution attempts. I wonder if when in DEV ENV, refreshing the digest for
BTW when I say What do you think? |
Does the same issue exist with images that are referenced from CSS when the images are changed? |
Isn't this the same problem as #123? |
Ran into the same issue, trying to replace css-bundling (postcss) with propshaft (nobuild). @dhh you mentioned that the once/campfire runs vanilla css (nobuild), would you mind sharing how you set it up? Based on this issue, I'd assume that you use multiple |
We use |
That can be a problem if you need a specific order of styles. The most representative case is to replace the default trix styles. Unless you name the file with something that is under in the alphabet than trix.css |
We need to fix the underlying issue. Just saying it’s not a problem for us because we don’t use includes. But you should be able to use includes. Propshaft needs to build a transient dependency tree like we do we with template caching. |
Same me for my projects. I've manually specified individual |
@equivalent Yeah, thanks - a |
Directly including the CSS via |
Fixed by #188 |
If I understood correctly the idea of Portshaft (pls correct me if I'm wrong ) then the way how to include css files would be:
in
app/assets/application.css
in
app/assets/bootstrap.css
I have the content ofbootstrap.css
from Bootstrap 5 download pagein
app/assets/my-custom.css
:my
app/views/layout/application.css
So far so good, I run rails server and load the localhost:3000
you can see the
<p>
is in redNow I change the
app/assets/my-custom.css
:I save the file and reload my localhost:3000
As you can see the change that I want the collor of
<p>
to be yellot was not picked up.Restarting of rails server don't help, only thing that helps is if I rename the file e.g. from
app/assets/my-custom.css
to app/assets/my-custom-xx.cssand alter the
app/assets/application.css`now it the
is yellow
rails new myapp -a propshaft
rails assets:precompile
The text was updated successfully, but these errors were encountered: