Created
May 2, 2011 18:37
-
-
Save aseemk/952109 to your computer and use it in GitHub Desktop.
Less on Node: @import path isn't relative to stylesheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express.createServer(); | |
app.configure(function () { | |
app.use(express.compiler({ | |
src: __dirname, | |
enable: ['less'] | |
})); | |
app.use(express.static(__dirname)); | |
app.use(express.errorHandler({ | |
dumpExceptions: true, | |
showStack: true | |
})); | |
}); | |
app.listen(8888); | |
console.log('Listening at http://localhost:8888/ ...'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@COLOR: 'red'; | |
.container (@marginVert: 1em) { | |
margin: @marginVert auto; | |
} | |
html { | |
color: @COLOR; | |
.container(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import 'a'; | |
body { | |
color: @COLOR; | |
.container(2em); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Gist doesn't show directories in filenames; place
a.less
andb.less
inside astyles
directory next toapp.js
.)Run this Express app (
node app.js
), open your browser, and view http://localhost:8888/styles/a.css -- it should properly return:But if you try to visit http://localhost:8888/styles/b.css in your browser, it won't work. Your node terminal will show:
Seems incorrect, no? When I debugged, it seems that Less operates off of the current working directory -- which is the directory above
styles
if you rannode app.js
.@import
paths should work relative to the stylesheet, no? That's how regular CSS works in the browser, and I'm guessing LESS in the browser too.