-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
86 lines (78 loc) · 2.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
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
val commonSettings = Seq(
version := "0.1",
scalaVersion := "2.12.8",
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-opt:l:method",
"-opt:l:inline",
"-opt-inline-from:**"
)
)
lazy val rockstar = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("rockstar"))
.settings(commonSettings ++ Seq(
name := "rockstar",
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "fastparse" % "2.1.0",
"com.lihaoyi" %%% "scalatags" % "0.6.7",
"com.lihaoyi" %%% "utest" % "0.6.3" % "test",
"io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M13",
),
testFrameworks += new TestFramework("utest.runner.Framework")
))
.jsSettings(Seq(
test := {}
))
lazy val rockstarJS = rockstar.js
lazy val rockstarJVM = rockstar.jvm
lazy val frontend = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Full)
.in(file("frontend"))
.settings(commonSettings ++ Seq(
name := "frontend",
test := {},
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "scalatags" % "0.6.7",
"io.github.cquiroz" %%% "scala-java-time" % "2.0.0-M13",
)
))
.jsSettings(
Seq(
libraryDependencies ++= Seq(
"org.querki" %%% "jquery-facade" % "1.2",
"org.scala-js" %%% "scalajs-dom" % "0.9.6",
"io.lemonlabs" %%% "scala-uri" % "1.1.4",
"com.lihaoyi" %%% "ujson" % "0.6.6",
"com.github.karasiq" %%% "scalajs-bootstrap-v4" % "2.3.2"
),
jsDependencies ++= Seq(
"org.webjars" % "jquery" % "3.3.1" / "jquery.js" minified "jquery.min.js",
"org.webjars" % "bootstrap" % "4.1.2" / "js/bootstrap.bundle.js" minified "js/bootstrap.bundle.min.js"
)
)
)
.dependsOn(rockstar)
lazy val frontendJS: Project = frontend.js
lazy val frontendJVM: Project = frontend.jvm
def combineFiles(inFiles: File*)(outfile: File): Unit = {
IO.write(outfile, inFiles.map(IO.read(_)).reduce(_ + _))
println(s"Copying ${inFiles.length} files into ${outfile.getCanonicalPath}")
}
frontendJS / Compile / fastOptJS := {
val result = (frontendJS / Compile / fastOptJS).value
val base = frontendJS.base / "target" / "scala-2.12"
combineFiles(base / "frontend-jsdeps.js", base / "frontend-fastopt.js")(baseDirectory.value / "bundle" / "static" / "js" / "rs-dep.js")
combineFiles(base / "frontend-fastopt.js")(baseDirectory.value / "bundle" / "static" / "js" / "rs.js")
result
}
frontendJS / Compile / fullOptJS := {
val result = (frontendJS / Compile / fullOptJS).value
val base = frontendJS.base / "target" / "scala-2.12"
combineFiles(base / "frontend-jsdeps.js", base / "frontend-opt.js")(baseDirectory.value / "bundle" / "static" / "js" / "rs-dep.js")
combineFiles(base / "frontend-opt.js")(baseDirectory.value / "bundle" / "static" / "js" / "rs.js")
result
}