-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
variable in @import statement #410
Comments
additionally it would be good if it could be used in selectors
|
+1 @DarkoBa. Needed feature |
Just changed my username from darkoba to arnaudgaudin due to professionnal reasons ;-)... @anru, thanks for the +1, can't wait for this feature ! |
I implemented this feature - in the near future (probably Monday) I make pull request |
see #426 |
any update on this? |
Is this happening or not happening? It would be really useful. |
my use case for selectors was just added 3 days ago in 93b23d2 |
I would also like to use variables for @import statements. Until support is added, it would be nice to document that variables are not interpreted for import @Statements; I tried numerous variations before finding this issue: @COMMON-ROOT-DIR: "../../../../../common/trunk";
// All these don't work.
@import "@{COMMON-ROOT-DIR}/css/variables.less";
@import url("@{COMMON-ROOT-DIR}/css/variables.less");
@import `"@{COMMON-ROOT-DIR}" + "/css/variables.less")`; etc. |
+1 |
+1 please please please! |
This is a must have feature. |
Is this the cause of the erroneously translated URLs ?My file is
and the the output is simply
myStyle.less is importing
The less files are in all in here
The problem is URLs like
are erroneously tranlated to
instead of
I am using WinLess, not the browser. |
changed to high priority because of all the requests and closed above duplicates |
+1 |
+1 |
1 similar comment
+1 |
+1 indeed. |
+1 |
yes.. its been marked high priority..! It would be nice to sort out all the import related bugs (and this feature request) at the same time - presuming other committers think its a good idea. I think its a good idea. |
+1 |
I actually need some of these features sooner rather than later, so I'm going to be dragging over pull requests into my own fork. Less.js Canary anyone? |
If a pull request is provided without API changes I will pull it, otherwise it will have to wait till I get round to looking at this. |
I have a node.js instance running this: https://github.com/SlyTrunk/less.js-server So I can curl a local URL for .less files to be compiled to .css. Doesn't matter what language you're writing your site in. |
I used to maintain dotless but its too much to port everything I do here. |
@bdalziel That is not an optimal solution. It would work for a local environment where only I work, but as a team I don't want to make them install Node and NPM and then RECESS or whatever is needed. Especially when we deploy the code to production or another team takes over. Backend developers are not very found of adding new installs to the project as they usually automate the deployment process and the LESS minification is done runtime. |
My team shares a development machine so it's optimal for us. You could also have a single server and have the node module return the compiled CSS over http rather than writing directly to the file system. Just sharing what works for me - understand it won't work for everyone. |
If you're using pre-processed languages (like LESS, CoffeeScript, Jade, etc.), your developers should expect to have to run some sort of local build tool in order to compile their code. LESS is a node module first and foremost. The fact that it has a browser implementation at all is just lucky. Check out Grunt for doing local builds, and also consider automating the deployment of tools for your developers. |
We are not using less.js to compile the LESS in the browser, that would cost the performance a lot. We are using a C# implementation that serves the files (CSS / JS) based on the env and it handled versioning and caching of the files. Plus, it stores in memory, not on the disk. Things are a bit different in .NET world. Personally I'm using Grunt for minifying, compiling LESS / Stylus, linting, testing, etc. But that doesn't work very well when it comes to working with TFS and VS, which locks all the files and can only be worked on in VS. Otherwise we have to manually checkout for edit each file we are about to work outside of VS. Though, yesterday we found a pretty good tool for System.Web.Optimization which is what we use to handle whatever means bundling scripts and styles, minifying, transforming, etc. It's called BundleTransformer, it works really well and it uses V8 to parse the node scripts (like less.js). This way we always can use the latest versions of these preprocessors and we can still take advantage of in memory storage, caching and versioning. (I know that Node is not yet capable of doing in memory storage of the styles or scripts runtime, which is what I would like to have because I use node for small projects most of the time). @bdalziel Yes, that might work for your team, but in our case it would never work. @Soviut We cannot use Grunt for builds, we compile C# / C++ on build. And you cannot handle deployments of such projects with Grunt, VS handles that for us with just a few configs. We have to all kinds of scripts and commands during deployment on the remote server which is something that Grunt cannot do (it's a JavaScript Task Runner), plus we use IIS to serve content and it doesn't play well with node if we were to use some Node server instance on the server that listens for incoming connections so we can run commands. And doing this with Node would consume a lot of time and resources whereas using TFS, VS, or other Microsoft tools we have that out of the box. Of course this applies for large projects, because for small websites that I do in my personal time, I prefer to work with Node and Express or Ruby and Sinatra, lately, that allows me to use Grunt for running deployment tasks and other local operations like lint, test with Karma the frontend functionality, unit test my Node scripts, etc. I really enjoy working with Node, because it's very close to what I've been used to, but it just doesn't play very well with .NET, which sometimes makes me very sad. |
I did say that Grunt is good for LOCAL builds. Even then, you can have grunt to compile to a "dist" sub-task which can conveniently put all compiled files in a "dist" folder. Visual Studio or a build step should have no trouble dealing with precompiled and minified files your grunt task generated. Grunt can do anything your build scripts can do since it can call shell scripts on windows, OSX or Linux exactly the same way visual studio does. Grunt and LESS compilations can be handled on the server. Finally, IIS is just another server like Apache or Nginx. It has all the same rules for redirecting, rewriting and aliasing URLs that any other webserver has. I used to do a lot of .NET development, and it can easily play well with node. So can Python, so can Ruby, so can Go, etc. |
You can use any LESS compiler to build the CSS as you go, and build your C# website project with the CSS as you normally do. So basically, edit LESS outside of VS, save to CSS. Build everything else in VS. |
Also, you should also be able to call external tasks from your build scripts. There are pre/post compile hooks that should allow you to easily call a grunt task or the lessc compiler directly every time someone hit's F5 in VS. Similarly, you should be able to do the same thing on deployment build scripts. |
I got
while
works perfectly as well as
BTW using lessc with Less v 1.5.1 |
So, variable interpolation of imports is still not working in imported files. @lukeapage What's the "master issue" that you're tracking this on, since this one is closed and there are related duplicates? |
Hi I'm having the following issue with @imports too. I have in a file file base.less: And then I want to redefine the variable from outside: like this But the value of @{dFolderPath} is not redefined and it still has the default value. This works for variables not used in imports. Can you fix it for imports? Any comments how easy is to fix this, I just need to have it! Point me in the code of the less so I can fix it? |
@ltoshev There's currently a known bug about this. This feature only works correctly when used in the root document, unfortunately. |
Well same problem here, I have a bower component that references to other bower component ( bootstrap ). So if I use the component "standalone" I have Eg: |
+1 |
@rossbb: Currently, you can use variables inside of import statements within the same file. // client_123.less
@clientID: '123';
@theme: 'happy';
@import "clients/@{clientID}/variables";
@import "themes/@{theme}/base"; After this issue is resolved, you'll be able to use those variables in import statements of other imported files too. |
+1 |
@tublitzed and all, I just finished #2246 and it should fix all these use-cases. There is one situation that won't work, to do with overriding variables which i will add to the pull request, but would appreciate any testing of that branch as its a tricky thing to do. |
Released in v2 beta 2. |
👍 for @import "@{url}/less/file.less" |
@joeSaad Just in case, you do realize this feature is implemented quite a while ago, do you? |
I'm still having an issue with this. It works fine with less v2.7.3. But breaks in less v3.9.0. This doesn't work, @defaultSiteVariables: "~semantic-ui-less/themes/default/globals/site.variables";
@import "@{defaultSiteVariables}";
@siteDir: "~semantic-ui-less"
@import "@{siteDir}/themes/default/globals/site.variables"; This works, @import "~semantic-ui-less/themes/default/globals/site.variables"; I'm compiling this using Aha, just noticed that issue is being discussed here: #2772 But is there any workaround ? |
Having the same issue using Less with Angular 8. Any updates?
I tried updating to latest, didn't work. The console outputs the following:
|
same issue in
I found it ! My import has interdependence which will cause loop error. SO variables import can find this hiding error.
Is ok when I don't use variables import, but error throw when :
|
@SheldonLaw Causing a loop ( |
The lastest version introduced the possibility to "access the value of an abstract property from a string using { } operators" (section "String interpolation" in http://lesscss.org/#-string-interpolation).
But the problem is that it doesn't work in import statements. It would be great to write code such like this :
//define the template
@mainTemplate: "BaseTheme";
//import the template
@import "_templates/@{mainTemplate}/Config/_ConfigTemplateDefault.less";
I don't know if it is possible to resolve this issue, but it would be great !
The text was updated successfully, but these errors were encountered: