-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.sbt
39 lines (35 loc) · 1.04 KB
/
web.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
import scala.sys.process._
lazy val buildFrontend = taskKey[Unit]("Builds frontend")
buildFrontend := {
val log = streams.value.log
val frontDir = baseDirectory.value / "frontend"
val npmInstall = Process(Seq("npm", "install"), frontDir)
val npmBuild = Process(Seq("npm", "run", "build"), frontDir)
val retCode = npmInstall #&& npmBuild ! log
val frontendBuildDir = baseDirectory.value / "frontend" / "build"
val resourceDir = resourceManaged.value / "main" / "web"
for {
(from, to) <- frontendBuildDir ** "*" pair Path.rebase(
frontendBuildDir,
resourceDir
)
} yield {
Sync.copy(from, to)
to
}
if (retCode != 0)
throw new IllegalStateException("Frontend build failed")
}
Compile / resourceGenerators += Def.task {
val frontendBuildDir = baseDirectory.value / "frontend" / "build"
val resourceDir = resourceManaged.value / "main" / "web"
for {
(from, to) <- frontendBuildDir ** "*" pair Path.rebase(
frontendBuildDir,
resourceDir
)
} yield {
Sync.copy(from, to)
to
}
}