Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

allow processing of .less.css in addition to .less files #315

Closed
wants to merge 2 commits into from

6 participants

@jamie-pate

allow *.less.css files to be processed in addition to *.less files
in case a webserver refuses to serve *.less files

@ricardobeat

This doesn't sound right to me on three levels:

  1. I don't think LESS should encourage using wrong file extensions, LESS files are not CSS.
  2. It's not that hard to configure a server for serving .less files properly
  3. .less shouldn't be deployed to live servers anyway...
@jamie-pate

ah, but .less.css files are not css files either.
Not everyone has control over their hosting solution (or in cases like mine the person who does charges $100/h to fix stuff like this)

@jamie-pate jamie-pate closed this
@jamie-pate jamie-pate reopened this
@lukeapage
Owner

@matthewdl @Synchro are you happy for this to be closed?

@lukeapage
Owner

I think a variation on this

#823

should be pulled instead (but with a different option name)

@Synchro
Owner

It hadn't occurred to me that import didn't work like that already! Does it need to enforce file names anyway?

@lukeapage
Owner
@matthew-dean

Several people have asked for variations of this. Flagging files with .CSS extensions (or other extensions, like .aspx) to be imported, interpreted, and compiled as LESS seems okay, since there can be legitimate server limitations with naming a file .less. Rather than try to solve all those server abnormalities, an author should be able to say to the parser, "Look, this IS really a LESS file." I agree that simply naming .less.css doesn't sufficiently cover it. Something like #less on the URL or something like that could be used for force less import.

@matthew-dean

@Synchro Alexis's (@cloudhead) idea was to use the same CSS syntax for LESS import, and essentially "smart-switch" the behavior of importing. If it ended in CSS, preserve the @import call as is (because, of course, there are many cases where you want the @import to continue to exist). If it ends in .LESS, then feed it into the parser chain. It works in 99% of cases. It's these edge cases that might become difficult for devs.

One alternative to futzing with URLs is to create a duplicate syntax for LESS imports. In fact, I was about to mention @include as a way to force LESS importing, and then figured it might have been suggested....

Yep: Issue #560. I shot it down, but it's probably an even simpler and more straightforward syntax then appending a bunch of characters to your URL.

So, you could do:

@include url(imreallyalessfile.css);  /* interpret this sucker as LESS */

To me, that may be cleaner than stuff like this:

@import url(imreallyalessfile.css?noreally=imlesssrslyuguys);

The second option is how the solution in #823 reads to me. Thoughts?

@jamesrdf

I think the @include syntax makes the most sense.

@lukeapage
Owner

yes. So all agreed that we close #823 and close this one, and proceed with #560.. ?

@lukeapage lukeapage closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 13, 2011
  1. @jamie-pate

    Modified to allow precompiling of *.less.css files as well as *.less …

    jamie-pate authored
    …files (server won't serve up .less files)
  2. @jamie-pate
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/less/tree/import.js
View
2  lib/less/tree/import.js
@@ -23,7 +23,7 @@ tree.Import = function (path, imports) {
this.path = path.value.value || path.value;
}
- this.css = /css$/.test(this.path);
+ this.css = /css$/.test(this.path) && !/less\.css$/.test(this.path);//precompile less.css and .less files!
// Only pre-compile .less files
if (! this.css) {
Something went wrong with that request. Please try again.