Last active
September 3, 2016 02:23
-
-
Save leon/6669138 to your computer and use it in GitHub Desktop.
Playframework 2.2 Grunt Runner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "GruntApp" | |
version := "1.0-SNAPSHOT" | |
libraryDependencies ++= Seq( | |
jdbc, | |
anorm, | |
cache | |
) | |
play.Project.playScalaSettings | |
playRunHooks <+= baseDirectory.map(base => Grunt(base / "app" / "assets")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import Keys._ | |
import java.net._ | |
import java.io.File | |
import play.PlayRunHook | |
/* | |
Grunt runner should be in project directory to be picked up by sbt | |
*/ | |
object Grunt { | |
def apply(base: File): PlayRunHook = { | |
object GruntProcess extends PlayRunHook { | |
var process: Option[Process] = None | |
override def beforeStarted(): Unit = { | |
Process("grunt dist", base).run | |
} | |
override def afterStarted(addr: InetSocketAddress): Unit = { | |
process = Some(Process("grunt run", base).run) | |
} | |
override def afterStopped(): Unit = { | |
process.map(p => p.destroy()) | |
process = None | |
} | |
} | |
GruntProcess | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment