node.js - Express.js + Less: How to configure properly -


i tried modules 'less' , 'less-middleware'. tried different code-snipplets have found in tutorials. there no documentation available. can please explain how configue express.js , less, less getting precompiled properly?!

use following questions guideline:

  1. shall use either 'less' module or 'less-middleware' module? official/supported way? superior?
  2. how should directory-structure in /public like? (any specific folders need? 'styles'/'less'/'css'? or yourself?)
  3. how configure express app regarding directory-structure (from question 2). (static files , compiler options or less-middleware, directories important here)
  4. how reference precompiled stylesheet html? (with .less or .css? reference type? directory-path?)

would nice if answer :-)

this solution work express 2.x.

i have found solution, helps someone:


1. less or less-middleware

i using less because have read official port. not sure difference since there no documentation available.

2. directory structure:

your directory structure doesn't matter less. highly recommended have public folder serves static content javascript, , less, css or image files.

3. app config:

you need 2 specific things make less working properly:

first, compiler, compiles less files:

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

and second, show express find static files!

    app.use(express.static(__dirname + '/public')); 

both should point public folder!

4. html

    <link rel="stylesheet" href="/styles/bootstrap.css"> 

point directly root-less file, lies somewhere in public folder.

5. less files

thanks this answer know went wrong time. there kind of bug in less.js. not find less files import in root file. you have add correct path every import!!!

replace @import "reset.less"; @import "/public/styles/reset.less"; every import have!

et voilĂ ... :-)


thank's helped issue. have @ wes johnson's answere. think has nice solution somehow didn't work me...


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -