type less css in your sbt projects
a friendly css companion for coffeescripted-sbt using the less 1.3.0 embedded compiler.
all(for less) # compiles all less source files regardless of freshness less # compiles less source files charset(for less) # character encoding used in file IO (defaults to utf-8) mini(for less) # setting for compiled minification (false by default) filter(for less) # filter for files included by the plugin exclude-filter(for less) # filter for files ignored by the plugin unmanaged-sources(for less) # lists resolved less sources clean(for less) # deletes compiled css config:source-directory(for less) # where less files will be resolved from config:resource-managed(for less) # where compiled css will be copied to
In your plugin definition, add
addSbtPlugin("me.lessis" % "less-sbt" % "0.1.10")
If you have not already added the sbt community plugin resolver, add this here as well with
resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))( Resolver.ivyStylePatterns)
Then in your build definition, add
This will append
less-sbt's settings for the
To add them to other configurations, use the provided
.less files under your project's
src/main/less directory. After compiling less sources, you can find the compiled css under
using less's built-in css minification
lesscss provides a built-in minifier which you can to to shink your compiled css. To override the default
mini setting, add following to your build definition after including the less settings.
(LessKeys.mini in (Compile, LessKeys.less)) := true
changing target css destination
To change the default location of compiled css files, add the following to your build definition
(resourceManaged in (Compile, LessKeys.less)) <<= (crossTarget in Compile)(_ / "your_preference" / "css")
Some lesscss projects, like Twitter's Bootstrap project contain one main
.less file which imports multiple
.less files using the @import feature of lesscss. To achieve the same style of compilation with less-sbt, set the
filter defined by less-sbt to the target of compilation.
(LessKeys.filter in (Compile, LessKeys.less)) := "your_main.less"
This will build a single
your_main.css file which includes all of the @imported style definitions.
You will find all custom
less-sbt keys within the
Have an issue? Tell me about it
I'll take them where they make sense. Please use a feature branch in your fork, i.e. git checkout -b my-cool-feature, and if possible, write a scripted test for it.
Doug Tangren (softprops) 2011-2012