Connect middleware providing a fallback for missing CSS files to corresponding LESS files
PLEASE NOTE: You should use this only during development. For production LESS should be precompiled.
This middleware checks for each request:
- Determines if requested file is a CSS file.
- If yes, looks for the requested CSS file.
- If not found, looks for a LESS file with the same name.
- If found, compiles the LESS file and delivers it, ending the request.
In all other cases, it just calls next()
and finishes processing.
Use NPM to install connect-css-to-less-fallback
:
npm install connect-css-to-less-fallback --save
Then load it in your app:
var express = require('express');
var cssToLessFallback = require('connect-css-to-less-fallback');
var app = express();
// just use it with the default options
app.use(cssToLessFallback());
You can provide an options object to the cssToLessFallback
function:
app.use(cssToLessFallback({
// the website root folder (default: '.')
root: './public',
// any less plugin you want to use (default: [])
plugins: [autoPrefix],
// if set to true true, it embeds sourcemaps (default: false)
sourceMap: true
}));
0.0.1 Initial version
Licensed under the MIT license