JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q60263F
  • License MIT

Compiles LESS on a per request basis in Express

Package Exports

  • express-less-middleware

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-less-middleware) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

##Express LESS Middleware

This middleware is designed to compile LESS on the fly. Depends on LESS npm module, obviously.

###Installing

npm install --save express-less-middleware

Should only be used for development. LESS should be compiled during a build process

###What this does (per request)

  1. Determines if file requested is: (if conditions aren't met it runs next())
    1. requested via GET method
    2. a CSS file
  2. Looks for CSS file requested
    • if found it will let it go through the original flow via next
  3. Looks for a LESS file with the same name as the CSS file requested
    • if LESS file is found it will read that file and compile it to CSS and deliever the response
  4. If no LESS or CSS file is found, it will give you a 404 like usual

###What this doesn't do

  1. Look for changes on save (if you use it, you won't need a grunt watch on less files)

###Example

var http         = require( 'http' );
var express      = require( 'express' );
var app          = express();
var lessCompiler = require( 'express-less-middleware' );

// everything else that has to do with configuring

// you should only use this when developing. Not meant for production
app.configure( 'dev', function() {
    // this must be "used" before express.use( express.static() ) or it will not work (no next())
    app.use( lessCompiler );
});

// other stuff relative to your express app

http.createServer( app ).listen( 8000 );

####License

MIT