-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbuild.sbt
89 lines (81 loc) · 3.14 KB
/
build.sbt
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import sbtcrossproject.{crossProject, CrossType}
lazy val commonSettings = {
organization := "org.http4s"
version := "0.0.1-SNAPSHOT"
scalaVersion := "2.12.7"
crossScalaVersions := Seq(scalaVersion.value, "2.11.12")
}
val Http4sVersion = "0.20.0-M1"
val utestV = "0.6.7"
val scalaJsDomV = "0.9.8"
val scalaTagsV = "0.6.8"
val circeV = "0.11.2"
val catsEffectV = "1.0.0"
// This function allows triggered compilation to run only when scala files changes
// It lets change static files freely
def includeInTrigger(f: java.io.File): Boolean =
f.isFile && {
val name = f.getName.toLowerCase
name.endsWith(".scala") || name.endsWith(".js")
}
lazy val shared =
(crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("shared"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "scalatags" % scalaTagsV,
"io.circe" %%% "circe-core" % circeV,
"io.circe" %%% "circe-generic" % circeV,
"io.circe" %%% "circe-parser" % circeV
// "org.typelevel" %% "cats-effect" % catsEffectV
)
)
lazy val sharedJvm = shared.jvm
lazy val sharedJs = shared.js
lazy val backend = (project in file("backend"))
.settings(
name := "http4s-scalajsexample--backend"
)
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-blaze-server" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion,
"ch.qos.logback" % "logback-classic" % "1.2.3"
),
// Allows to read the generated JS on client
resources in Compile += (fastOptJS in (frontend, Compile)).value.data,
// Lets the backend to read the .map file for js
resources in Compile += (fastOptJS in (frontend, Compile)).value
.map((x: sbt.File) => new File(x.getAbsolutePath + ".map"))
.data,
// Lets the server read the jsdeps file
(managedResources in Compile) += (artifactPath in (frontend, Compile, packageJSDependencies)).value,
// do a fastOptJS on reStart
reStart := (reStart dependsOn (fastOptJS in (frontend, Compile))).evaluated,
// This settings makes reStart to rebuild if a scala.js file changes on the client
watchSources ++= (watchSources in frontend).value,
// Support stopping the running server
mainClass in reStart := Some("org.http4s.scalajsexample.Server")
)
.dependsOn(sharedJvm)
lazy val frontend = (project in file("frontend"))
.settings(
name := "http4s-scalajsexample-frontend"
)
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings: _*)
.settings(
// Build a js dependencies file
skip in packageJSDependencies := false,
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
// Put the jsdeps file on a place reachable for the server
crossTarget in (Compile, packageJSDependencies) := (resourceManaged in Compile).value,
testFrameworks += new TestFramework("utest.runner.Framework"),
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % scalaJsDomV,
"com.lihaoyi" %%% "utest" % utestV % Test
)
)
.dependsOn(sharedJs)