-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
124 lines (115 loc) · 4.76 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
val scalaV = "2.13.5"
val akkaV = "2.6.12"
val akkaHttpV = "10.2.3"
val upickleVersion = "1.2.3"
val scalaJsDomVersion = "1.1.0"
val specs2Version = "4.8.0"
val airstreamV = "0.12.0"
val laminarV = "0.12.1"
val waypointV = "0.3.0"
val airframeLogV = "20.10.0"
val sttpClientV = "2.2.9"
val scalinguaV = "1.0"
val scalaTestV = "3.2.2"
ThisBuild / scapegoatVersion := "1.4.8"
lazy val root = project
.in(file("."))
.settings(name := "sklable", version := "0.1")
.aggregate(frontend, backend)
// Scala-Js frontend
lazy val frontend =
project
.in(file("frontend"))
.enablePlugins(ScalaJSPlugin, Scalingua)
.settings(commonSettings: _*)
.settings(
scalaJSUseMainModuleInitializer := true,
Compile / compileLocalesStrategy := "InlineBase64",
Test / compileLocalesStrategy := "InlineBase64",
libraryDependencies ++= Seq(
"com.raquo" %%% "airstream" % airstreamV,
"com.raquo" %%% "laminar" % laminarV,
"com.raquo" %%% "waypoint" % waypointV,
"com.softwaremill.sttp.client" %%% "core" % sttpClientV,
"ru.makkarpov" %%% "scalingua" % scalinguaV,
"org.scalatest" %%% "scalatest" % scalaTestV % Test
)
)
.dependsOn(sharedJs)
// Akka Http based backend
lazy val backend =
project
.in(file("backend"))
.settings(commonSettings: _*)
.settings(backendDependencies: _*)
.settings(
Compile / resourceGenerators +=
(Def.taskDyn {
val env = buildEnv.value
env match {
case BuildEnv.Development =>
Def.task {
val f1 = (frontend / Compile / fastOptJS).value.data
val f1SourceMap = f1.getParentFile / (f1.getName + ".map")
val indexTemplate = IO.read((Compile / sourceDirectory).value / "templates" / "index.html")
val indexOutput = (Compile / resourceManaged).value / "web" / "index.html"
IO.write(indexOutput, indexTemplate.replace("<script-name>", "frontend-fastopt.js"))
Seq(f1, f1SourceMap, indexOutput)
}
case BuildEnv.Production =>
Def.task {
val f1 = (frontend / Compile / fullOptJS).value.data
val indexTemplate = IO.read((Compile / sourceDirectory).value / "templates" / "index.html")
val indexOutput = (Compile / resourceManaged).value / "web" / "index.html"
IO.write(indexOutput, indexTemplate.replace("<script-name>", "frontend-opt.js"))
Seq(f1, indexOutput)
}
}
}).taskValue
// watchSources += WatchSource(frontend.base)
)
.settings(
Universal / mappings += {
val confFile = buildEnv.value match {
case BuildEnv.Development => "conf/development.conf"
case BuildEnv.Production => "conf/production.conf"
}
((Compile / sourceDirectory).value / confFile) -> "application.conf",
},
)
.enablePlugins(JavaServerAppPackaging)
.dependsOn(sharedJvm)
// Shared code
lazy val shared =
crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Full)
.in(file("shared"))
.settings(commonSettings: _*)
.settings(
libraryDependencies += "com.lihaoyi" %%% "upickle" % upickleVersion,
libraryDependencies += "org.wvlet.airframe" %%% "airframe-log" % airframeLogV,
libraryDependencies += "org.scalatest" %% "scalatest" % scalaTestV % "test"
)
lazy val sharedJvm = shared.jvm
lazy val sharedJs = shared.js
def backendDependencies =
Seq(
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream" % akkaV,
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-stream-typed" % akkaV,
"org.wvlet.airframe" %% "airframe-log" % airframeLogV,
"org.slf4j" % "slf4j-jdk14" % "1.7.30",
"com.typesafe.akka" %% "akka-http" % akkaHttpV,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpV,
"com.lihaoyi" %% "upickle" % upickleVersion,
"org.specs2" %% "specs2-core" % specs2Version % "test",
"org.scalatest" %% "scalatest" % scalaTestV % "test"
)
)
def commonSettings =
Seq(
scalaVersion := scalaV,
scalacOptions ++= Seq("-deprecation", "-feature", "-encoding", "utf8", "-unchecked", "-Xlint")
)
backend / Compile / mainClass := Some("server.SklableServer")