Gradle CSS Plugin

Tasks and tools for working with CSS in Gradle


Project maintained by eriwen Hosted on GitHub Pages — Theme by mattgraham

Quick Start

Managing your CSS in a Gradle build is super easy now! Just add this to your build.gradle file:

// Grab the plugin from a Maven Repo automatically
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.eriwen:gradle-css-plugin:1.11.1'
    }
}

// Invoke the plugin
apply plugin: 'css'

// Declare your sources
css.source {
    dev {
        css {
            srcDir "app/styles"
            include "*.css"
            exclude "*.min.css"
        }
    }
}

// Specify a collection of files to be combined, then minified and finally GZip compressed.
combineCss {
    source = css.source.dev.css.files
    dest = "${buildDir}/all.css"
}

minifyCss {
    source = combineCss
    dest = "${buildDir}/all-min.css"
    yuicompressor { // Optional
        lineBreakPos = -1
    }
}

gzipCss {
    source = minifyCss
    dest = "${buildDir}/all.2.0.4.css"
}

LESS Support

css.source {
    dev {
        css {
            srcDir "app/styles"
            include "*.less"
        }
    }
}

lesscss {
    source = css.source.dev.css.files
    dest = "${buildDir}/styles"
}

Supports CSS Lint v0.9.10

csslint {
    source = css.source.dev.css.files
    dest = "${buildDir}/csslint.out"
    options { // Optional
        format = 'lint-xml'
        warnings = ['box-model', 'empty-rules', 'duplicate-properties']
        errors = []
    }
}

Available Tasks and Options

combineCss

minifyCss (Uses the YUI Compressor)

gzipCss

less

csslint

What, you want more? Let me know!

License

This software is provided under the Apache License, Version 2.0.

See Also

The Gradle JS Plugin!

Endorse eriwen on Coderwall