An open API service indexing awesome lists of open source software.

https://github.com/edvin/libsass-filter

Compiles SASS to CSS on-the-fly
https://github.com/edvin/libsass-filter

Last synced: 5 months ago
JSON representation

Compiles SASS to CSS on-the-fly

Awesome Lists containing this project

README

        

# libsass-filter

## Compiles SASS to CSS on-the-fly

libsass-filter uses [libsass-maven-plugin](https://gitlab.com/haynes/libsass-maven-plugin)
which uses [libsass](https://github.com/sass/libsass) under the covers via Jna native bindings.
You are however not required to use Maven, we just use the sass bindings from libsass-maven-plugin to access libsass.

It also supports autoprefixing via [autoprefixer](https://github.com/postcss/autoprefixer).

### Installation

Include the following Maven dependency in your pom.xml:


no.tornado
libsass-filter
4.0.0

The default settings are good for development, as your stylesheets will be recompiled
on every request. This takes less than 100ms on my test setup with over 40 imports.

For production use you should use `libsass-maven-plugin` to precompile your stylesheets.
Optionally, configure this filter to cache and compress in web.xml:


SassFilter
no.tornado.libsass.SassFilter

outputStyle
compressed


cache
true



autoprefix
true


autoprefixBrowsers
last 2 versions, ie 10


autoprefixerPath
postcss -u autoprefixer




SassFilter
*.css




SassFilter
*.xhtml

### Configuration

All configuration options are set via init-params in web.xml.

* `cache` (true|false) - Cache after the initial request. Default: false
* `watch` (true|false) - Watch for file changes and recompile. Useful together with `cache`. Default: false
* `outputStyle` (nested, expanded, compact, compressed) - Output CSS style. Default: compact.
* `includePaths` - Additional include paths
* `autoprefix` (true|false) - Add prefixes using [autoprefixer](https://github.com/postcss/autoprefixer) (requires `npm install --global autoprefixer`)
* `autoprefixBrowsers` - What browsers to prefix for, defaults to `last 2 versions, ie 10`
* `autoprefixerPath` - Path to autoprefixer with arguments, defaults to `postcss -u autoprefixer`.

### Usage

All requests to `.css` and optionally `.css.xhtml` are checked for a `.scss` counterpart,
and if found, the SASS resources are compiled and returned as a CSS stylesheet.

The default no-cache mode is so fast that you would probably never need to cache the
result during development, but if you want to use this filter in production instead of
precompiling your stylesheets, make sure you set `cache` to `true`.