Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.
/ gradle-sass Public archive

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

Notifications You must be signed in to change notification settings

SalomonBrys/gradle-sass

Repository files navigation

DEPRECATED

This library is deprecated. You can still use it. It is not going any where.

However, it is not maintained anymore.

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.2.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()
}
Style

You can configure the CSS output style to expanded (by default) or compressed:

sassCompile {
   style = compressed  // Valid values: expanded, compressed. Default: expanded.
}
Sources

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

sassCompile {
    source = fileTree("src/whynot/css")
    include { /*...*/ }
    exclude { /*...*/ }
}
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