-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sbt
140 lines (131 loc) · 4.52 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name := "cheep"
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / scalaVersion := "2.13.7"
ThisBuild / useSuperShell := false
// ScalaFix configuration
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
val catsVersion = "2.6.1"
val circeVersion = "0.14.1"
val http4sVersion = "0.23.6"
val http4sDomVersion = "0.2.0"
val logbackVersion = "1.2.3"
val munitVersion = "1.0.0-M1"
val munitCatsVersion = "1.0.0"
val scalajsReactVersion = "2.0.0"
val monocleVersion = "3.1.0"
val sharedSettings = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsVersion,
"io.circe" %%% "circe-core" % circeVersion,
"io.circe" %%% "circe-generic" % circeVersion,
"io.circe" %%% "circe-parser" % circeVersion,
"dev.optics" %%% "monocle-core" % monocleVersion,
"org.scalameta" %%% "munit" % munitVersion % Test,
"org.typelevel" %%% "munit-cats-effect-3" % "1.0.6" % Test
),
scalacOptions ++= Seq(
"-Yrangepos",
"-Ymacro-annotations",
"-Werror"
),
testFrameworks += new TestFramework("munit.Framework")
)
val deploy = taskKey[Unit]("Deploy the frontend to the backend asset location")
val build = taskKey[Unit]("Format, compile, and test")
lazy val data = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("data"))
.settings(
sharedSettings,
build := {
Def.sequential(scalafixAll.toTask(""), scalafmtAll, Test / test).value
}
)
lazy val backend = project
.in(file("backend"))
.settings(
sharedSettings,
libraryDependencies += guice,
// run / fork := true,
run / javaOptions += s"-Dtodone.assets=${((baseDirectory.value) / "assets").toString}",
build := {
Def.sequential(scalafixAll.toTask(""), scalafmtAll, Test / test).value
}
)
.dependsOn(data.jvm)
.enablePlugins(PlayScala)
lazy val frontend = project
.in(file("frontend"))
.settings(
sharedSettings,
Compile / npmDependencies ++= Seq(
"react" -> "17.0.2",
"react-dom" -> "17.0.2",
"react-proxy" -> "1.1.8"
),
Compile / npmDevDependencies ++= Seq(
"file-loader" -> "6.0.0",
"style-loader" -> "1.2.1",
"css-loader" -> "3.5.3",
"html-webpack-plugin" -> "4.3.0",
"copy-webpack-plugin" -> "5.1.1",
"webpack-merge" -> "4.2.2",
"postcss-loader" -> "4.1.0",
"postcss" -> "8.2.6",
"tailwindcss" -> "2.0.1",
"autoprefixer" -> "10.0.2",
"react-icons" -> "4.1.0"
),
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core-bundle-cats_effect" % scalajsReactVersion,
"com.github.japgolly.scalajs-react" %%% "extra" % scalajsReactVersion,
"com.github.japgolly.scalajs-react" %%% "extra-ext-monocle3" % scalajsReactVersion,
"org.http4s" %%% "http4s-dom" % http4sDomVersion,
"org.http4s" %%% "http4s-client" % http4sVersion,
"org.http4s" %%% "http4s-circe" % http4sVersion,
"org.scala-js" %%% "scalajs-dom" % "2.0.0"
),
// TODO temporary workaround for https://github.com/scala-js/scala-js/issues/4601
Compile / fullOptJS / scalaJSLinkerConfig ~= { _.withCheckIR(false) },
Test / fullOptJS / scalaJSLinkerConfig ~= { _.withCheckIR(false) },
webpack / version := "4.43.0",
startWebpackDevServer / version := "3.11.0",
webpackResources := baseDirectory.value / "webpack" * "*",
fastOptJS / webpackConfigFile := Some(
baseDirectory.value / "webpack" / "webpack-fastopt.config.js"
),
fastOptJS / webpackDevServerExtraArgs := Seq("--inline", "--hot"),
fastOptJS / webpackBundlingMode := BundlingMode.LibraryOnly(),
fullOptJS / webpackConfigFile := Some(
baseDirectory.value / "webpack" / "webpack-opt.config.js"
),
Test / webpackConfigFile := Some(
baseDirectory.value / "webpack" / "webpack-core.config.js"
),
Test / requireJsDomEnv := true,
build := {
Def
.sequential(
scalafixAll.toTask(""),
scalafmtAll,
Test / test,
Compile / fullOptJS,
deploy
)
.value
},
deploy := {
val fs = (Compile / fullOptJS / webpack).value
val outDir = (backend / baseDirectory).value / "public"
fs.foreach { f =>
val input = f.data
val output = outDir / (f.data.name)
println(s"Deploying $input to $output")
sbt.io.IO.copyFile(input, output)
}
}
)
.enablePlugins(ScalaJSBundlerPlugin)
.dependsOn(data.js)