Skip to content

A Gradle plugin to download & run the official dart-sass release with Gradle

Notifications You must be signed in to change notification settings

Travelcompositor/gradle-sass

 
 

Repository files navigation

Gradle Sass

Gradle plugin to download and run Sass. Compatible with Gradle continuous build.

This plugin is compatible with Kotlin Gradle DSL & offers the exact same API between Groovy & Kotlin DSLs.

The Sass source files must, by default, be located in src/main/sass.

Install

plugins {
    id("com.github.salomonbrys.gradle.sass") version "1.1.0"
}

Sass access configuration

Download

By default, the plugin downloads Dart-Sass (Sass official implementation).

If need be, you can configure the download:

sass {
    download {
        version = "1.13.4" // Default: "0.14.3".
        downloadBaseUrl = "http://mirror.example.com" // Default: "https://github.com/sass/dart-sass/releases/download".
        outputDir = file("wherever/I/want") // Default: "$gradleUserHome/sass".
    }
}

Local

You can instruct the plugin to run a locally installed version of sass instead of downloading a release:

sass {
    local()
}

You can configure the path to use:

sass {
    local {
        path = "/opt/dart-sass/sass" // Default: "sass".
    }
}

Sass execution configuration

By default, the plugin creates a sassCompile task of type SassTask.

Output

You can configure the output directory:

sassCompile {
    outputDir = "web/css" // default: "$buildDir/sass".
}

Source map

You can configure the sourcemap generation to be in a file:

sassCompile {
    fileSourceMap() // This is the task's default
}

You can configure it:

sassCompile {
    fileSourceMap {
        embedSource = true // Default: false.
        url = absolute // Valid values: relative, absolute. Default: relative.
    }
}

You can configure the sourcemap generation to be embedded in the generated CSS:

sassCompile {
    embedSourceMap()
}

You can configure it:

sassCompile {
    embedSourceMap {
        embedSource = true // Default: false.
    }
}

You can configure no sourcemap generation at all:

sassCompile {
    noSourceMap()
}

Sources

SassTask tasks are SourceTasks, which means you can configure them just like any SourceTask:

sassCompile {
    source = fileTree("src/whynot/css")
    include { /*...*/ }
    exclude { /*...*/ }
}

Style

You can choose expanded (default) or compressed style output

sassCompile {
    style = "compressed"  //Default: expanded
}

Create new taks

You can easily create SassTask tasks:

Groovy DSL:

task("mySassCompile", type: SassTask) {
    source = fileTree("src/main/my-sass")
}

Kotlin DSL:

task<SassTask>("mySassCompile") {
    source = fileTree("src/main/my-sass")
}

About

A Gradle plugin to download & run the official dart-sass release with Gradle

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%