A SASS plugin for Gradle. The plugin uses Java sass compiler to compile sass files that is using libsass.
-
Clone or download project
-
Execute
gradle uploadArchivesto add project to local repositories -
Add the plugin like this:
apply plugin: "com.t1c.gradle.jsass.plugin"
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath "com.t1c.gradle.jsass:gradle-jsass-plugin:1.0.0"
classpath "io.bit3:jsass:5.2.0"
}
}
General configuration for the plugin goes inside a sassOptions block in your build file and will applied to all tasks. For example:
sassOptions {
sassDir = project.file('src/scss')
cssDir = project.file('src/main/webapp/css')
outputStyle = "compressed"
}
Parameters supported by the plugin are:
-
sassDir: the source directory where you keep .scss and/or .sass files. -
cssDir: the target directory to output compiled CSS. -
mainFilename: name of main sass file to compile. Default value:main.scss. -
outputStyle: output style for the generated css code. Default value:compressed. Available options are:nested,expanded,compact,compressed -
sourceComments: if you want inline source comments. -
sourceMapEmbed(boolean): embed sourceMappingUrl as data uri. -
saveSourceMap(boolean): save source map file -
watch(boolean): watch files for modification and recompile
Installation of libsass on Ubuntu
You need to have the git package installed to clone the sassc and libsass repositories, and the build-essential package to run make. Check if they are not already installed.
> sudo apt-get install git > sudo apt-get install build-essential
Next you need to download sassc and libsass by cloning the repositories using the latest release (3.3.6). In Ubuntu install them for all users in /usr/local/lib/.
> cd /usr/local/lib/ > sudo git clone https://github.com/sass/sassc.git --branch 3.3.6 --depth 1 > sudo git clone https://github.com/sass/libsass.git --branch 3.3.6 --depth 1
To make sassc you need to define the SASS_LIBSASS_PATH variable. In Ubuntu use /etc/environment for all users.
> sudo vim /etc/environment # Append line SASS_LIBSASS_PATH="/usr/local/lib/libsass" *NOTE* to exit vim saving the changes press *ESC* then *:wq* then *Enter* > sudo source /etc/environment > cd /usr/local/lib/sassc/ > sudo make
Declaring SASS_LIBSASS_PATH variable in /etc/environment doesn’t seem to work for everyone. An alternative could be declaring the variable just before running make.
> cd /usr/local/lib/sassc/ > SASS_LIBSASS_PATH="/usr/local/lib/libsass" make
Create a symbolic link to sassc.
> cd /usr/local/bin/ > sudo ln -s ../lib/sassc/bin/sassc sassc
Execute sassc -h for display the help message