-
Notifications
You must be signed in to change notification settings - Fork 135
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
Control or increase the depth that imported less files are watched to refresh cache #41
Comments
👍 |
Hi @metaskills , if you need to see the issue in a test case here is how. You can modify I found that if an import is using full path "twitter/bootstrap/variables", then changes will be watched. But if it's imported as "variables" in a file "twitter/bootstrap/bootstrap.less", then it's not been watched. |
+1 This has been plaguing me for a year. |
After looking through the other issues in this repo, it appears that this issue has been brought up several times, with several "fixes". There seems to be something fundamentally wrong with the way @imports are handled in less-rails that is keeping sprockets from detecting a stale asset when a change is made a few levels into the @import tree. I'd be happy to take a stab at fixing it myself, if someone could push me in the right direction. |
Sorry no recommendations, but we do have a good test system and you could easily grep the code as well as the git history on import stuff and get some clues as to what we have done before. A tested patch that does not break existing functionality and other tests would surely be merged in. |
I'll take a look, and see what I can find. The problem is definitely that changes made more than 1 @import deep are not reflected on the next request. |
Also, it seems that if all of your @import statements are relative to the app/assets/stylesheets directory, rather than that files directory, then this "caching" issue goes away, and stale assets are expired correctly. Thus, a simple fix could be to convert all @import paths to be relative to app/assets/stylesheets before doing any of the actual @import stuff to them. Just a thought |
But assets could be in vendor/assets or any other gems asset path. |
Hence that is why any changes need to be tested with less-rails-bootstrap too. |
When using the following setup:
//= require_self
@import 'projects';
@import 'projects/index';
@import 'projects/show'; Editing However, removing //= require_self
@import 'projects/index';
@import 'projects/show'; Will trigger a recompile. Is this really an issue? I would say not. How is Sprockets supposed to follow all of the Just something one has to remember when importing LESS files. ✌️ |
I have found somewhat a dirty workaround for this. You can actually use Sprocket's |
I am sorry for cross posting this, but this seem related to #46 (comment) |
+1 to fix this |
Closing this issue, our behavior is the exact same as Sass and it is why |
I have discovered two workaround for this issue. First workaround: rename all
stylesheets/project/index.css.less
stylesheets/project/calendar.css.less || stylesheets/project/autocomplete.css.less Second (dirty) workaround: put all
stylesheets/index.less
stylesheets/calendar.less || stylesheets/autocomplete.less Sass-rails doesn't seem to have this issue. I have tried to have 4 level of |
The first workaround isn't a very good solution. I've found that the |
@metaskills can you give a bit more info about this statement? I'm not following what you're saying here:
I'm not sure if you're saying you can't have depend_on and also import a LESS file in your application.css.less file? I'm also confused about using it "at the top level .css.less file one level lower down" ... is this saying use a .css.less file in a subfolder under app/assets/stylesheets in order to have depends_on work? |
My only advice with the time I have is to recommend that someone dive deep into sass-rails and their Importer class which is used in their template handler. They do a good job at processing imports and calling |
I have three levels of @metaskills
It seems that less-rails is only watching the top two levels for changes before reparsing the files
The text was updated successfully, but these errors were encountered: