robfletcher / gradle-compass

A SASS / Compass plugin for Gradle
Apache License 2.0
59 stars 39 forks source link

= Gradle Compass plugin

A http://sass-lang.com/[SASS] / http://compass-style.org/[Compass] plugin for http://gradle.org/[Gradle]. The plugin uses JRuby to install and run Compass.

image:https://travis-ci.org/robfletcher/gradle-compass.svg?branch=master["Build Status", link="https://travis-ci.org/robfletcher/gradle-compass"]

image::https://api.bintray.com/packages/robfletcher/gradle-plugins/compass-gradle-plugin/images/download.svg[link="https://bintray.com/robfletcher/gradle-plugins/compass-gradle-plugin/_latestVersion"]

== Tasks

The plugin adds the following tasks:

=== compassCompile

Compiles all SASS files. Equivalent to the compass compile command. The task supports incremental build.

=== compassWatch

Compiles and watches all SASS files. Equivalent to the compass watch command.

=== compassVersion

Prints out the compass version.

=== compassConfig

Writes compass configuration out to config/compass.rb.

== Installation

Add the plugin like this:

[code, lang=groovy]

apply plugin: "com.github.robfletcher.compass"

buildscript { repositories { jcenter() maven { url "http://dl.bintray.com/robfletcher/gradle-plugins" } } dependencies { classpath "com.github.robfletcher:compass-gradle-plugin:2.0.5" } }

== Configuration

General configuration for the plugin goes inside a compass block in your build file and will apply to all tasks. You can also specify configuration properties on the individual tasks (for example you may want to set environment = "production" on the compileSass and debugInfo = true on watchSass). For example:

[code, lang=groovy]

compass { cssDir = file("public/styles") sassDir = file("src/main/sass") }

=== Configuration parameters

The full set of parameters supported by the plugin is…

==== Paths

==== Compilation options

==== Command line output

==== Dependency options

=== Specifying the Compass version

By default the plugin will use the latest version of Compass available. If you need a specific version you can set the version using Gradle's dependency management. For example:

[code, lang=groovy]

dependencies { compass "rubygems:compass:1.0.1" }

Gems are installed using the JRuby Gradle plugin. The Compass plugin creates a special "compass" configuration that is used by all the plugin's tasks.

=== Cleaning output

The Compass plugin creates a cleanCompassCompile task automatically that will delete compiles CSS. The main clean task will also delete CSS assuming cssDir is inside the project's build directory.

=== Using additional gems

You can use Compass extensions from Ruby gems by adding dependencies to the compass configuration. The plugin will automatically add a --require argument for each gem when invoking Compass commands. For example to use the Breakpoint extension:

[code, lang=groovy]

dependencies { compass "rubygems:breakpoint:2.5.0" }

=== Automatically recompiling stylesheets while other tasks are running

A typical use-case is to run compassWatch in the background while another task runs your web-server application. This is very easy with the Compass plugin.

Assuming you're using the http://www.gradle.org/docs/current/userguide/application_plugin.html[Application plugin]'s run task you would configure your build with:

[code, lang=groovy]

run.dependsOn compassWatchStart run.finalizedBy compassWatchStop

=== Advanced Gem Install Options

You can specify additional options to gem install:

[code, lang=groovy]

compass { gems = [ [ name: "compass", version: "0.12.7", ], [ name: "compass-css-arrow", version: "0.0.4", opts: ["--ignore-dependencies"], ], ] }

= Version history

=== 2.0.5

=== 2.0.5

=== 2.0.4

=== 2.0.3

=== 2.0.2

=== 2.0

=== 1.0.10

=== 1.0.9

=== 1.0.8

=== 1.0.7

=== 1.0.6

=== 1.0.5

=== 1.0.4

[app-plugin]: