1
0

Webpack.scala 748 B

1234567891011121314151617181920212223242526272829303132
  1. package support
  2. import scala.sys.process._
  3. import play.api.templates.Html
  4. object Webpack {
  5. val BIN = "./node_modules/.bin/webpack-dev-server"
  6. val PORT = "9001"
  7. val OPTS = Seq(
  8. "--inline",
  9. "--output-public-path", s"http://localhost:$PORT/assets/",
  10. "--port", PORT,
  11. "--hot"
  12. )
  13. val hotReloadScriptUrl = s"http://localhost:$PORT/assets/bundle.js"
  14. val hotReloadScript = Html(s"<script type='text/javascript' src='$hotReloadScriptUrl'></script>")
  15. var process: Option[Process] = None
  16. def startHotReloadServer() {
  17. if(process.isEmpty) {
  18. val logger = ProcessLogger(println, println)
  19. process = Some(Process(BIN, OPTS).run(logger))
  20. }
  21. }
  22. def stopHotReloadServer() {
  23. process.map(_.destroy())
  24. }
  25. }