aboutsummaryrefslogtreecommitdiff
path: root/project/util.scala
blob: 497adc10dee4fcb9a57aeac43afd845cff13f3d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sbt._
import sbt.Keys._
import play._
import play.PlayImport.PlayKeys._
import scala.scalajs.sbtplugin.ScalaJSPlugin
import scala.scalajs.sbtplugin.ScalaJSPlugin.ScalaJSKeys._
import com.typesafe.sbt.packager.universal.UniversalKeys

package object util extends UniversalKeys {

  implicit class ScalaJSPlayProject(val scalajvm: Project) {

    val jsOutputDir = settingKey[File]("Directory for javascript files")

    def dependsOnJs(scalajs: Project): Project = scalajvm.settings(
      jsOutputDir := (classDirectory in Compile).value / "public" / "lib",
      compile in Compile <<= (compile in Compile) dependsOn (fastOptJS in (scalajs, Compile)),
      dist <<= dist dependsOn (fullOptJS in (scalajs, Compile)),
      stage <<= stage dependsOn (fullOptJS in (scalajs, Compile)),
      playMonitoredFiles += (scalaSource in (scalajs, Compile)).value.getCanonicalPath
    ).settings(
      Seq(packageLauncher, fastOptJS, fullOptJS) map { packageJSKey =>
        crossTarget in (scalajs, Compile, packageJSKey) := jsOutputDir.value
      }: _*
    )

  }

}