-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sbt
83 lines (68 loc) · 2.49 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
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
name := "MBFFZ"
version := "0.1"
scalaVersion := "2.12.8"
val copyFrontendFastOpt = taskKey[File]("Return main process fast compiled file directory.")
lazy val fastOptCompileCopy = taskKey[Unit]("Compile and copy paste projects and generate corresponding json file.")
val copyFrontendFullOpt = taskKey[File]("Return main process full compiled file directory.")
lazy val fullOptCompileCopy = taskKey[Unit]("Compile and copy paste projects, and generate corresponding json file.")
lazy val `shared` = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(
libraryDependencies ++= Seq(
"fr.hmil" %%% "roshttp" % "2.1.0",
"io.suzaku" %%% "boopickle" % "1.3.0",
"com.lihaoyi" %%% "upickle" % "0.7.1",
// scala tags for making type safe html
"com.lihaoyi" %%% "scalatags" % "0.6.7"
)
)
.jvmSettings(
libraryDependencies ++= Seq(
"org.scala-js" %% "scalajs-stubs" % "1.0.0-RC1"
)
)
lazy val sharedJVM = `shared`.jvm
lazy val sharedJS = `shared`.js
lazy val `server` = project.in(file("backend"))
.settings(
libraryDependencies ++= Seq(
// cask
"com.lihaoyi" %% "cask" % "0.1.9",
"com.lihaoyi" %% "ujson" % "0.7.1"
)
)
.dependsOn(sharedJVM)
lazy val `frontend` = project.in(file("frontend"))
.enablePlugins(ScalaJSPlugin)
.settings(
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.5",
"com.raquo" %%% "laminar" % "0.6"
),
scalaJSUseMainModuleInitializer := true,
copyFrontendFastOpt := {
(fastOptJS in Compile).value.data
},
copyFrontendFullOpt := {
(fullOptJS in Compile).value.data
}
)
.dependsOn(sharedJS)
val copyPath: String = "backend/src/main/resources/frontend/"
fullOptCompileCopy := {
val frontendDirectory = (copyFrontendFullOpt in `frontend`).value
IO.copyFile(frontendDirectory, baseDirectory.value / copyPath / "frontend-scala.js")
IO.copyFile(
frontendDirectory.getParentFile / "frontend-opt.js.map",
baseDirectory.value / copyPath / "frontend-opt.js.map"
)
}
fastOptCompileCopy := {
val frontendDirectory = (copyFrontendFastOpt in `frontend`).value
IO.copyFile(frontendDirectory, baseDirectory.value / copyPath / "frontend-scala.js")
IO.copyFile(
frontendDirectory.getParentFile / "frontend-fastopt.js.map",
baseDirectory.value / copyPath / "frontend-fastopt.js.map"
)
}
run in Compile := (run in Compile in server).evaluated