-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
148 lines (137 loc) · 6.84 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
141
142
143
144
145
146
147
148
import sbt.Keys._
import sbt.Project.projectToRef
// Treat eviction issues as warning
ThisBuild / evictionErrorLevel := Level.Warn
// a special crossProject for configuring a JS/JVM/shared structure
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("app/shared"))
.settings(
scalaVersion := BuildSettings.versions.scala,
libraryDependencies ++= BuildSettings.sharedDependencies.value
)
lazy val sharedJvmCopy = shared.jvm.settings(name := "sharedJVM")
lazy val sharedJsCopy = shared.js.settings(name := "sharedJS")
lazy val jsShared: Project = (project in file("app/js/shared"))
.settings(
name := "jsShared",
scalaVersion := BuildSettings.versions.scala,
scalacOptions ++= BuildSettings.scalacOptions,
libraryDependencies ++= BuildSettings.scalajsDependencies.value,
// use uTest framework for tests
testFrameworks += new TestFramework("utest.runner.Framework")
)
.enablePlugins(ScalaJSWeb)
.dependsOn(sharedJsCopy)
lazy val client: Project = (project in file("app/js/client"))
.settings(
// Basic settings
name := "client",
version := BuildSettings.version,
scalaVersion := BuildSettings.versions.scala,
scalacOptions ++= BuildSettings.scalacOptions,
fullOptJS / scalacOptions ++= Seq("-Xelide-below", "WARNING"),
libraryDependencies ++= BuildSettings.scalajsDependencies.value,
// use Scala.js provided launcher code to start the client app
scalaJSUseMainModuleInitializer := true,
// use uTest framework for tests
testFrameworks += new TestFramework("utest.runner.Framework"),
// Execute the tests in browser-like environment
Test / requiresDOM := true,
// Fix for bug that produces a huge amount of warnings (https://github.com/webpack/webpack/issues/4518).
// Unfortunately, this means no source maps :-/
fastOptJS / emitSourceMaps := false,
// scalajs-bundler NPM packages
Compile / npmDependencies ++= BuildSettings.npmDependencies(baseDirectory.value / "../../.."),
// Custom webpack config
Test / webpackConfigFile := None,
fastOptJS / webpackConfigFile := Some(baseDirectory.value / "../webpack.dev.js"),
fullOptJS / webpackConfigFile := Some(baseDirectory.value / "../webpack.prod.js"),
// Enable faster builds when developing
webpackBundlingMode := BundlingMode.LibraryOnly(),
Test / webpackBundlingMode := BundlingMode.LibraryAndApplication()
)
.enablePlugins(ScalaJSBundlerPlugin, ScalaJSWeb)
.dependsOn(sharedJsCopy, jsShared)
lazy val webworkerClient: Project = (project in file("app/js/webworker"))
.settings(
// Basic settings
name := "webworker-client",
version := BuildSettings.version,
scalaVersion := BuildSettings.versions.scala,
scalacOptions ++= BuildSettings.scalacOptions,
fullOptJS / scalacOptions ++= Seq("-Xelide-below", "WARNING"),
libraryDependencies ++= BuildSettings.scalajsDependencies.value,
// use Scala.js provided launcher code to start the client app
scalaJSUseMainModuleInitializer := true,
// Fix for bug that produces a huge amount of warnings (https://github.com/webpack/webpack/issues/4518).
// Unfortunately, this means no source maps :-/
fastOptJS / emitSourceMaps := false,
// scalajs-bundler NPM packages
Compile / npmDependencies ++= BuildSettings.npmDependencies(baseDirectory.value / "../../.."),
// Custom webpack config
Test / webpackConfigFile := None,
fastOptJS / webpackConfigFile := Some(baseDirectory.value / "../webpack.dev.js"),
fullOptJS / webpackConfigFile := Some(baseDirectory.value / "../webpack.prod.js"),
// Enable faster builds when developing
webpackBundlingMode := BundlingMode.LibraryOnly()
)
.enablePlugins(ScalaJSBundlerPlugin, ScalaJSWeb)
.dependsOn(sharedJsCopy, jsShared)
lazy val manualTests: Project = (project in file("app/js/manualtests"))
.settings(
// Basic settings
name := "manual-tests",
version := BuildSettings.version,
scalaVersion := BuildSettings.versions.scala,
scalacOptions ++= BuildSettings.scalacOptions,
fullOptJS / scalacOptions ++= Seq("-Xelide-below", "WARNING"),
libraryDependencies ++= BuildSettings.scalajsDependencies.value,
// use Scala.js provided launcher code to start the client app
scalaJSUseMainModuleInitializer := true,
// Fix for bug that produces a huge amount of warnings (https://github.com/webpack/webpack/issues/4518).
// Unfortunately, this means no source maps :-/
fastOptJS / emitSourceMaps := false,
// scalajs-bundler NPM packages
Compile / npmDependencies ++= BuildSettings.npmDependencies(baseDirectory.value / "../../.."),
// Custom webpack config
Test / webpackConfigFile := None,
fastOptJS / webpackConfigFile := Some(baseDirectory.value / "../webpack.dev.js"),
fullOptJS / webpackConfigFile := Some(baseDirectory.value / "../webpack.prod.js"),
// Enable faster builds when developing
webpackBundlingMode := BundlingMode.LibraryOnly()
)
.enablePlugins(ScalaJSBundlerPlugin, ScalaJSWeb)
.dependsOn(sharedJsCopy, jsShared)
// Client projects
lazy val clientProjects = Seq(client, webworkerClient, manualTests)
lazy val server = (project in file("app/jvm"))
.settings(
name := "server",
version := BuildSettings.version,
scalaVersion := BuildSettings.versions.scala,
scalacOptions ++= BuildSettings.scalacOptions,
libraryDependencies ++= BuildSettings.jvmDependencies.value,
libraryDependencies += guice,
javaOptions := Seq("-Dconfig.file=conf/application.conf"),
Test / javaOptions := Seq("-Dconfig.resource=test-application.conf"),
// connect to the client project
scalaJSProjects := clientProjects,
Assets / pipelineStages := Seq(scalaJSPipeline),
pipelineStages := Seq(scalaJSProd, digest, gzip),
// Expose as sbt-web assets some files retrieved from the NPM packages of the `client` project
// @formatter:off
npmAssets ++= NpmAssets.ofProject(client) { modules => (modules / "jquery").allPaths }.value,
npmAssets ++= NpmAssets.ofProject(client) { modules => (modules / "bootstrap").allPaths }.value,
npmAssets ++= NpmAssets.ofProject(client) { modules => (modules / "metismenu").allPaths }.value,
npmAssets ++= NpmAssets.ofProject(client) { modules => (modules / "font-awesome").allPaths }.value,
npmAssets ++= NpmAssets.ofProject(client) { modules => (modules / "startbootstrap-sb-admin-2").allPaths }.value,
// @formatter:on
// compress CSS
Assets / LessKeys.compress := true
)
.enablePlugins(PlayScala, WebScalaJSBundlerPlugin)
.disablePlugins(PlayFilters) // Don't use the default filters
.disablePlugins(PlayLayoutPlugin) // use the standard directory layout instead of Play's custom
.aggregate(clientProjects.map(projectToRef): _*)
.dependsOn(sharedJvmCopy)
// loads the Play server project at sbt startup
onLoad in Global := (Command.process("project server", _: State)) compose (onLoad in Global).value