sass-theme-api-middleware
v0.0.9
Published
Pass colors in url to scss, and then return and cache compiled css.
Downloads
10
Readme
Sass Theme Api Middleware
This express middleware allows you to create an api that returns dynamic and custom css based on the url of the request and Sass stylesheets. Variables are included in the url, e.g.
/urlBase/primaryColor/blue/secondaryColor/red
will pass the following sass to node-sass:
$primaryColor: red;
$secondaryColor: blue;
Usage
This middleware must be placed upstream from your static middleware. This is to allow the middleware to check if the sass needs to be recompiled.
Options
urlBase
: string, to remove from beginning of url path that is not a var/value pairpublicDir
: string, absolute path to public dir where compiled css is to be storedincludePaths
: array of strings, absolute paths of where sass imports will lookoutputStyle
: string, passed directly to node-sass, see node-sass for available optionsbeforeUrlVars
:function(queryParams)
callback function that is passed the url query parameters that should return a string to be added to sass before url vars, e.g. default palette importafterUrlVars
:function(filename)
callback function that is passed the filename of the css file requested in the url that should return a string to be added to sass after url vars, e.g. main import
Thanks
Heavily inspired by node-sass-middleware