Giter VIP home page Giter VIP logo

express-less-middleware's Introduction

##Express LESS Middleware Build Status Coverage Status

This middleware is designed to compile LESS on the fly.

###Installing

npm install express-less-middleware --save

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();

// this assumes that the publicly available folder is on the same directory level
// as the file that starts your express server
var lessCompiler = require( 'express-less-middleware' )();

// if that's not the case, initialize it with the path to your public/client-side folder
// the path should be relative to the directory where the file that starts your express server is
// ex) var lessCompiler = require( 'express-less-middleware' )( '../path/to/public/folder' );


// ....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

express-less-middleware's People

Contributors

vernak2539 avatar

Watchers

David Waltz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.