Node SASS Asset functions
To ease the transitioning from Compass to Libsass, this module provides some of Compass' asset functions for node-sass
NB Please note that the functions
option of node-sass is still experimental (>= v3.0.0).
Installation
npm install --save[-dev] node-sass-asset-functions
Usage
Basic usage is as easy as setting the functions
property:
var sass = ;var assetFunctions = ; sass;
You can specify the paths of your resources using the following options (shown with defaults):
images_path: 'public/images' fonts_path: 'public/fonts' http_images_path: '/images' http_fonts_path: '/fonts'
So if for example your images reside in public/img
instead of images/images
, you use it as follows:
var sass = ;var assetFunctions = ; sass;
Additional options
asset_host
: a function which completes with a string used as asset host.
sass;
asset_cache_buster
: a function to rewrite the asset path
When this function returns a string, it's set as the query of the path. When returned an object, path
and query
will be used.
sass;
A more advanced example:
Here we include the file's hexdigest in the path, using the hexdigest
module.
For example, /images/myimage.png
would become /images/myimage-8557f1c9b01dd6fd138ba203e6a953df6a222af3.png
.
var path = fs = hexdigest = ; sass;
Available functions
image-url($filename: null, $only_path: false)
image-width($filename: null)
image-height($filename: null)
font-url($filename: null, $only-path: false)
font-files($filenames...)
- and more to come
Usage with Grunt
Using this module with Grunt is just as easy:
var assetFunctions = ; module{ grunt;};
See also
node-sass-css-importer
: Import CSS files into node-sass
, just like sass-css-importer
did for Compass
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request