-
Notifications
You must be signed in to change notification settings - Fork 133
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
rake assets:precompile grabs all .less files #35
Comments
I just looked at sass-rails and could not see anything passed to the upper host rails application for assets precompile. Just basic configs in their dummy application. Can you point me to specific places and examples where you see sass-rails doing things that fixes this problem in their end? If so, we could mimic and it would be a good fix for us. |
Yeah, I looked in the same places. My guess right now is that they're doing it in the resolver - does that make sense to you? |
importer.rb:33
They also distinguish between a partial (starts with _) and non-partial. I'm not sure this is relevant or helpful in our case. |
For what it's worth, I'm seeing the same issue. I see undefined variable errors because individual .less files are being precompiled. Everything works fine in development. I plan to try pacovell's workaround. |
What needs to be done here? We ran into this issue today, and would love to fix it, or contribute towards a fix. |
For someone to fully investigate this issue and report how either sprockets and/or sass-rails handles this issue from their side. From what I can see, individual I just did a quick test using the less-rails-bootstrap-test project and found that none of these individual files located in the So perhaps people are just doing it wrong against less-rails as advertised usage? Either way, some one has to demonstrate the problem. |
Ok, so step 1, let's get a demo app going of the issue. We'll look at how sass-rails handles this too. I have experienced this issue locally, it seems to be worked around by removing the default proc that comes with rails (as it includes all assets except .css and .js (and application(.js|.css)) by default). The weird thing is, in the proc, if you print out the path passed into the proc, it shows less files as .css, but it also does this for sass, so I'm not sure if it matters. |
Just so you know, just making an app that shows the issue doe not mean it is a real issue. Like I was saying, you could be doing it wrong in how you layout the file. So far less-rails-bootstrap-test does not exhibit what your talking about and that of me is the gospel of how you should structure your pipeline files using less. |
Please see my fork of your test, I have the issue demonstrated there (added in this commit: bbhoss/less-rails-bootstrap-test@b77ed5e). Also, note that this all works in development mode, you only discover the failure when you precompile. For this to be designed behavior it seems quite odd, as Twitter bootstrap itself uses this paradigm (it uses mixins in files that are included below the mixins include in the main bootstrap.css). Thanks. |
Would it work if the file name is |
As I wrote above, I believe this is the key:
So somewhere, sass-rails is passing variables.css when it translates the name from variables.sass, but less-rails is passing variables without any extension. If we can find where that extension is removed and change it to .css instead, we will have the same behavior as sass-rails. The REASON you don't see the problem in less-rails-bootstrap is NOT because it isn't happening. It's because the two .less files, mixins and variables, don't have any dependencies on other files that must be loaded first, so it doesn't matter that they are loaded at any time. |
Are you sure? It looks to me like mixins.less needs to have the |
I added the above code to print out the assets. This is with a fresh clone of less-rails-bootstrap-test.
|
@metaskills I suspect because .border-radius() itself is included in a mixin, it may not be evaluated at that point. You can see from the printout above that the files are definitely being processed. |
OK, I see an empty |
For the elimination of any doubt, if I add
to variables.less, it will crash as below. @GrayLight is defined by twitter bootstrap variables.
|
@metaskills I tried custom.less, no dice, same error. @pacovell we worked around this locally by not precompiling any .less files, except the ones we specified. When we specify precompile to be just full_control.css.less (yes, we added the .less extension), it compiles as expected. Also, @metaskills I found an issue in the generated CSS:
|
@bbhoss My workaround looks like this:
.css.less files work fine (without any mod) because when the .less extension is stripped, it becomes .css, which is ignored by the default precompile function. |
Interested in this issue as well. |
Also ran into this issue. The workaround from @pacovell works for me. |
Just ran into this too. Huge thanks to @pacovell, the workaround works great. |
this worked for me.
|
I get this issue locally as well. I'm using a variant of the workaround given by @pacovell |
Awesome, thanks @pacovell ! I've been stuck on the same issue for a while. |
Same issue here. This is a real problem. Fact that @metaskills can find a case where it does not happen does not mean it does not exist :/ It grabs every file that it can find, sass works around this becouse partials there start with @pacovell Thanks for a workaround |
OK, these work arounds were just that. I was hoping someone would do the legwork and keep digging on top of @pacovell's great work and find the source of the issue. Here is the solution I came up with today, after an hour of digging. I found that sprockets Along those lines, I found that the def add_engine_to_trail(ext, klass)
@trail.append_extension(ext.to_s)
if klass.respond_to?(:default_mime_type) && klass.default_mime_type
if format_ext = extension_for_mime_type(klass.default_mime_type)
@trail.alias_extension(ext.to_s, format_ext)
end
end
end And I know the less-rails' |
Closing this issue, remember, just run |
application.css.less:
widget.css.less:
app/assets/stylesheets/widget has variables.less and header.less.
The engine is processing the widget directory in alphabetical order, paying no attention to the application or widget manifests. If I remove the require or import statements entirely, the widget directory is still processed.
The problem arises if header.less uses variables.less, then it is undefined because the processing is in alphabetical order instead of manifest order; then I get an undefined variable error:
variable @xyz is undefined
I think this is in error, since only files included in the manifest somewhere should be included. I investigated by adding a puts to the default precompile proc:
The filename (path) passed to the proc is 'variables' not 'variables.less'. If I compare to a sass-rails configuration, I see that the equivalent 'variables.sass' file is passed to the precompile proc as 'variables.css' so it is NOT compiled, yielding the proper behavior.
I'm not exactly sure where to fix this, but I'm happy to submit a pull if you can point me in the right direction. My workaround for the moment is to add '' (filenames without extensions) to the precompile proc exclude list.
The text was updated successfully, but these errors were encountered: