less.js icon indicating copy to clipboard operation
less.js copied to clipboard

less does not handle relative paths when used with express.js

Open BonsaiDen opened this issue 15 years ago • 14 comments

Using less as an compiler will break with relative import statements in .less files, see: http://stackoverflow.com/questions/4618257/node-js-express-js-how-to-render-less-css/4635200#4635200

BonsaiDen avatar Jan 08 '11 17:01 BonsaiDen

+1, this is pretty annoying

andrew avatar Aug 19 '11 20:08 andrew

Still annoying.

ricardobeat avatar Aug 27 '11 19:08 ricardobeat

I have this issue too, can you make a fix?

css/ b/b.less common/functions.less

b.less: @import "../common/functions.less";

css> lessc b/b.less css> file '../common/functions.less' wasn't found.

I use less.js on the development side, but when on prodution i use the compiled files. Any update on this?

Thx and congratz on the great work so far!

ricardovf avatar Aug 28 '11 23:08 ricardovf

Still here I see, but is this a less.js problem or an Express thing...?

awhillas avatar Sep 15 '11 21:09 awhillas

less problem, i dont use Express.

ricardovf avatar Sep 15 '11 21:09 ricardovf

above, this is resovled by current master branch, please replace your npm install less version, directly use less master branch. it's work for me. nodejs 6.1

xiaods avatar Nov 14 '11 06:11 xiaods

eager to see this work

samdelagarza avatar Nov 22 '11 18:11 samdelagarza

Great, thx a lot, ill test it.

ricardovf avatar Nov 22 '11 19:11 ricardovf

Express does not complies my less styles

app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.methodOverride()); app.use({ src: __dirname + '/public' }); app.use(app.router); app.use(express.compiler({ src: __dirname + '/public/stylo', enable: ['less'] })); app.use(express.static(__dirname + '/public')); });

anandof28 avatar Feb 02 '12 05:02 anandof28

@ricardovf is that working ?

anandof28 avatar Feb 02 '12 12:02 anandof28

@anandrc have you tried setting src: __dirname + '/public' instead?

ricardobeat avatar Feb 03 '12 08:02 ricardobeat

I have less 1.3.0, and my compiler is set to:

app.use(express.compiler({ src: __dirname + '/public', enable: ['less']}));

To make the imports work, I cannot use relative urls, I have to change them all to the following to make it work:

@import "/public/stylesheets/dashboard.less";
@import "/public/stylesheets/super_bar.less";

Otherwise it will just state [Object object] in the css.

mohamedmansour avatar Apr 25 '12 10:04 mohamedmansour

Is there no fix for this?

mhuggins avatar Jun 02 '12 18:06 mhuggins

using #331 as the central issue for this, closing as duplicate

lukeapage avatar Sep 01 '12 14:09 lukeapage