In this post I figured I will learn about sbt tasks and create on of my own. I've reached a stage where I've created a task that runs before compilation and compiles my sass.
val sassCompile = TaskKey[ Unit ]( "sassCompile" )
sassCompile := {
SassCompiler.compile( baseDirectory.value )
}
watchSources <++= baseDirectory map { path => ((path / "app" / "assets" ) ** "*.scss").get }
compile <<= (compile in Compile) dependsOn sassCompile
I do two things:
So what works:
What doesn't work:
When compilation is triggered automatically (by virtue of calling ~compile or ~run and then making a change (or even not making a change), sass compilation does not get called. So when I do play ~run, my sass compiler doesn't get invoked.
EDIT: If it helps, here is a similar question.
You need to change the last line to:
compile in Compile <<= (compile in Compile) dependsOn sassCompile
Explanation to this you can find here in "When to specify a scope" section.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With