This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
102 lines (94 loc) · 3.04 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
import sbt.{Def, *}
import scalajsbundler.sbtplugin.ScalaJSBundlerPlugin.autoImport.webpackEmitSourceMaps
lazy val buildFrontend = taskKey[Unit]("build-frontend")
lazy val root = project
.in(file("."))
.aggregate(common.jvm, common.js, backend, frontend.js, frontend.jvm, frontendCompile)
.settings(
name := "anonymous-poll",
version := "0.0.1"
)
lazy val backend = project
.in(file("./backend"))
.configs(IntegrationTest)
.settings(
name := "anonymous-poll-backend",
Settings.common,
Libraries.shared,
Libraries.jvm,
Defaults.itSettings,
IntegrationTest / parallelExecution := false // Sequential suites, parallel tests execution
)
.dependsOn(common.jvm)
lazy val frontendCompile = project
.enablePlugins(WebScalaJSBundlerPlugin)
.in(file("./frontend-output"))
.settings(
scalaJSProjects := Seq(frontend.js),
Assets / pipelineStages := Seq(scalaJSPipeline),
// triggers scalaJSPipeline when using compile or continuous compilation
Compile / compile := ((Compile / compile) dependsOn scalaJSPipeline).value
)
lazy val frontend = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.jsConfigure {
_.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin, WebScalaJSBundlerPlugin)
.settings(
Libraries.js,
scalaJSUseMainModuleInitializer := true,
webpackBundlingMode := BundlingMode.LibraryAndApplication(),
webpackEmitSourceMaps := false,
// Build frontend (JS)
buildFrontend :=
// TODO: Rewrite. Increase readability using Def.taskIf / Def.task
Def
.ifS(
Def.task(Option(System.getenv("POLL_IS_FULL_BUILD")).contains(true.toString))
)(
Def.task((Compile / fullOptJS / webpack dependsOn Compile / compile).value)
)(
Def.ifS(
Def.task(Option(System.getenv("POLL_IS_WEBPACK_BUILD")).contains(true.toString))
)(
Def.task((Compile / fastOptJS / webpack dependsOn Compile / compile).value)
)(
Def.task(
((Compile / fastOptJS).map(Seq(_)) dependsOn Compile / compile).value
)
)
)
.value
)
.dependsOn(common.js)
}
.jvmConfigure {
_.enablePlugins(HepekPlugin)
.settings(
Libraries.shared,
Libraries.html,
// Build frontend (HTML)
hepekTarget := target.value / "html",
buildFrontend := (Compile / hepek).value
)
.dependsOn(common.jvm)
}
.in(file("./frontend"))
.settings(
name := "frontend",
Settings.common
)
.configs(IntegrationTest)
lazy val common = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.jsConfigure {
_.enablePlugins(ScalaJSBundlerPlugin, ScalaJSWeb)
.settings(Libraries.js)
}
.in(file("./common"))
.configs(IntegrationTest)
.settings(
name := "anonymous-poll-shared",
Settings.common,
Libraries.shared,
Defaults.itSettings
)