-
Notifications
You must be signed in to change notification settings - Fork 47
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
Importing - Both CSS and Less #19
Comments
Things to keep in mind:
|
They implemented import over http pull 261 |
Some info on how less.js intends to implement variables in import: less/less.js#1108 |
Other related questions:
|
Here is how the wro4j handles the css @import directive. It is important to notice that when using less4j with wro4j, the css imports are processed properly and everything works out of the box. However, if you want to handle @import directives internally in less4j you have to implement a similar approach.... |
@alexo Thank you, it is good to know - I will start by modifying less4j to print From what I understood, less.js can import also .less files. Less files are included before compilation, so all included mixins and variables are available in the main file. Less.js treatment of |
Importing You can import .less files, and all the variables and mixins in them will be made available to the main file. The .less extension is optional, so both of these are valid: @import "lib.less"; If a file already has an extension or parameters, it will not get “.less” added on the end. If you want to import a CSS file, and don’t want LESS to process it, just use the .css extension: @import "lib.css"; The directive will just be left as is, and end up in the CSS output. This will occur for any import that ends in css, before url parameters. If you want to import a file only if it has not been imported already, use @import-once @import-once "lib.less"; @import-once will be the default behaviour of @import in 1.4.0 (taken from http://lesscss.org/#-importing) |
Need more input? |
I think that assuming the extension of imported resource by adding ".less" is a bit dangerous and adds no real value (just my opinion). Also the @import should work exactly the same as @import-once. Adding this kind of new capabilities to less language add nothing but more confusion to users. I'm mentioning these two points, just for sake of discussion. I'm wondering what do you think about it. |
I have no strong opinion about assuming the .less extension, just posted what it said on the less site. The problem could be though since it is on the less web site, import statements that work in other compilers will then not work here. I can always work my way around it easily, but still. I also added that "@import-once will be the default behaviour of @import in 1.4.0" does this mean ONLY in 1.4.0 or SINCE 1.4.0? |
As I understand it, Less.js collects all backward incompatible changes for 1.4.0. 1.4.0 was not released yet so I can not test it. I'm not always sure what are bugs and what are features. Less.js has many open issues related to
compiles into:
the same with
e.g. Is this a bug or a feature and I should not use |
Implementation of this kind of "features" should be postponed until there is a specification available. |
My thoughts on the suffix issue: As a general strategy, I think that port should behave as close to original compiler as reasonably possible. People should be able to take their existing projects and switch compilers without having to rewrite them. It may differ on apparent bugs or insignificant things (formatting, comments handling). So, I prefer to implement less.js way even if I would choose a different one in the same situation. Less.js is currently very responsive to suggestions and questions (they answered all mine within a day or two), so I do not think that there is a reason to fragment less language. So basically, I agree with @alexo on the suffix issue, but less.js does it, so I think that less4j should too. |
@alexo That sounds reasonable. @DBarbarian If I implement a simple version of import first, would that be enough for you? Import-once will import each file once regardless of ruleset it is in or media queries it has. The file will be considered CSS if its name ends with ".css" and less otherwise. CSS file import statement will be left as is and less file import will be compiled. The next version then can already have something while the analysis of full less.js import functionality will continue. Everything described in your comment would work, but not much more. Do you need urls with parameters |
A simple import does it for us. We have no need for any extra fancy stuff. We do not need any parameter functions. |
@alexo I have not thought about the best solution yet. Obviously, I will have to change the API. The compile method can take a file instead of string as a parameter or file path as an additional parameter. Any preferences? |
@SomMeri Ideally, you should leave the current method signature unchanged and expose a new method which takes the file as the argument. But you have to be aware about the limitation of this approach (ex: how to compile absolute referenced resources, when the File is unknown). |
@alexo The string based method (current) can treat every import as an attempt to import css file e.g., output original import statement. If the imported file name does not end with .less, it can produce warning or error. @DBarbarian OK, I will do simple import first. The other #83 issue then can be considered a request for simple import and be closed it when it will be done (to keep tracking of what was done and what was not done). Simple import seems to be simple enough to be planned for the next 0.0.10 milestone. This one can stay open until imports are fully solved. |
@alexo Yes, it certainly will be possible. I can also produce warning on such case, so user will be able get that information if he is interested. Warnings can be ignored, so it should not bother him if he does not care. |
@SomMeri related to this issue, I'm wondering how less4j would allow client code to provide a meaning for retrieving imported content? At the first glance, I couldn't figure this myself. In case this is not possible yet, would you consider adding some sort of ImportedResourceLocator interface which could be implemented by client. Thanks, |
@alexo Less4j uses Extend it and override three methods:
Then you just have to use |
Great, thanks!
|
@alexo If you want the |
Closing since new way of importing was already implemented. All unfinished import related things should have their own issue. |
Must have also this feature: less/less.js#410
The text was updated successfully, but these errors were encountered: