Skip to content

Instantly share code, notes, and snippets.

@marzocchi
Created September 10, 2012 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marzocchi/3693582 to your computer and use it in GitHub Desktop.
Save marzocchi/3693582 to your computer and use it in GitHub Desktop.
Configure Assetic's LessFilter
# Sample configuration for overriding Assetic's default LessFilter
# configuration in order to define one or more "load paths".
#
# Setting load paths allows to load libraries (such as Twitter's Bootstrap
# less sources) from different directories.
#
# Save this file in your bundle's `config` directory and import it into
# yor `services.yml` using the `imports` directive, eg.:
#
# imports:
# - { resource: assetic-less.yml }
#
# Link the stylesheets in your templates with:
#
# {% stylesheets '@FooBundle/Resources/public/css/*'
# filter="less" %}
#
# <link rel="stylesheet" href="{{ asset_url }}" type="text/css" />
#
# {% endstylesheets %}
#
parameters:
# Set to true to enable compression of the generated CSS.
less.compress: false
# Node executable's location.
less.node_bin: /usr/local/bin/node
# Node modules location (eg.: directory where npm installed "less",
# you'll find a "less" directory in there).
less.node_module_dir: /usr/local/lib/node_modules
# Where to look for "@imported" files.
#
# The following:
#
# @import "bootstrap.less"
#
# Will result in a "bootstrap.less" file being searched in the
# configured directory (after the default one, which is the
# directory contaning the asset being parsed).
less.bootstrap_less_sources: /Users/marzocchi/Desktop/lab/bootstrap/less
services:
foo.assetic.filter.less:
class: "Assetic\\Filter\\LessFilter"
arguments:
- %less.node_bin%
- [ %less.node_module_dir% ]
calls:
- [ addLoadPath, [ %less.bootstrap_less_sources% ] ]
- [ setCompress, [ %less.compress% ] ]
tags:
# Tag this service as an "assetic.filter", and give it the "less" alias
# to override the builtin "less" filter.
- { name: "assetic.filter", alias: "less" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment