Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SBT example scalajs and generated resources
import Dependencies._
import sbt.Keys._
import spray.revolver.RevolverPlugin._
import CustomKeys._
import Path.relativeTo
lazy val commonSettings = Seq(
organization := "com.edc4it",
version := "0.1.0",
scalaVersion := "2.11.5"
)
lazy val root = (project in file(".")).
settings(
name := "scalajs-spray-angular"
).
aggregate(service, client)
val scalajsOutputDir = Def.settingKey[File]("directory for javascript files output by scalajs")
lazy val service = (project in file("server")).
settings(commonSettings: _*).
settings(Revolver.settings: _*).
settings(
libraryDependencies ++= Seq(`spray-routing`, `spray-can`, `akka-actor`, `spray-json`),
compile in Compile <<= (compile in Compile) dependsOn (fastOptJS in(client, Compile)),
resourceGenerators in Compile <+= Def.task {
val files = ((crossTarget in(client, Compile)).value ** ("*.js" || "*.map")).get
val mappings: Seq[(File,String)] = files pair rebase((crossTarget in(client, Compile)).value, ((resourceManaged in Compile).value / "assets/").getAbsolutePath )
val map: Seq[(File, File)] = mappings.map { case (s, t) => (s, file(t))}
IO.copy(map).toSeq
}
)
lazy val client = (project in file("client")).
settings(commonSettings: _*).
enablePlugins(ScalaJSPlugin).
settings(
libraryDependencies ++= Seq(`scalajs-dom`.value, `scalajs-jquery`.value, `scalajs-angulate`.value)
).
settings(
skip in packageJSDependencies := false,
persistLauncher := true,
persistLauncher in Test := false,
relativeSourceMaps := true ,
)
import sbt._
// import scala.scalajs.sbtplugin.ScalaJSPlugin._
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
object Dependencies {
val akkaVersion = "2.3.5"
val sprayVersion = "1.3.2"
val sprayJsonVersion = "1.3.1"
val `spray-can` = "io.spray" %% "spray-can" % sprayVersion
val `spray-routing` = "io.spray" %% "spray-routing" % sprayVersion
val `spray-json` = "io.spray" %% "spray-json" % sprayJsonVersion
val `akka-actor` = "com.typesafe.akka" %% "akka-actor" % akkaVersion
val `scalajs-dom` = Def.setting("org.scala-js" %%% "scalajs-dom" % "0.8.0")
val `scalajs-jquery` = Def.setting("be.doeraene" %%% "scalajs-jquery" % "0.8.0")
val `scalajs-angular` = Def.setting("com.greencatsoft" %%% "scalajs-angular" % "0.3")
val `scalajs-angulate` = Def.setting( "biz.enef" %%% "scalajs-angulate" % "0.1")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.