I have a ScalaJS + Play project with an SBT build file, and am using amongst others the plugin sbt-web-scalajs
. There is a total of 4 subprojects in my build.sbt
. Here's the beginning of that file:
import sbt.Keys.libraryDependencies
val myScalaVersion = "2.13.1"
val scalaTestPlusVersion = "5.1.0"
val scalaJsDomVersion = "1.0.0"
val scalaTagsVersion = "0.8.6"
val scalatagsrxVersion = "0.5.0"
val circeVersion = "0.13.0"
val rosHttpVersion = "3.0.0"
val quillVersion = "3.5.2"
val pgDriverVersion = "42.2.5"
val scriptsVersion = "1.1.4"
val apacheCommonsMailV = "1.5"
useJCenter := true
scalaVersion in ThisBuild := myScalaVersion
scalaJSStage in Global := FullOptStage
lazy val backend = (project in file("backend")).settings(commonSettings).settings(
scalaJSProjects := Seq(frontend, sec_frontend),
pipelineStages in Assets := Seq(scalaJSPipeline),
pipelineStages := Seq(gzip),
pipelineStages := Seq(scalaJSProd, gzip),
compile in Compile := ((compile in Compile) dependsOn scalaJSPipeline).value,
scalaJSStage := FullOptStage,
isDevMode in scalaJSPipeline := false,
libraryDependencies ++= Seq(
"com.vmunier" %% "scalajs-scripts" % scriptsVersion,
jdbc,
evolutions,
"org.postgresql" % "postgresql" % pgDriverVersion,
"org.apache.commons" % "commons-email" % apacheCommonsMailV,
"io.getquill" %% "quill-jdbc" % quillVersion,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"org.scalatestplus.play" %% "scalatestplus-play" % scalaTestPlusVersion % "test",
guice,
specs2 % Test
)
).enablePlugins(PlayScala)
.dependsOn(sharedJvm)
lazy val frontend = (project in file("frontend")).settings(commonSettings).settings(
scalaJSUseMainModuleInitializer := true,
scalaJSStage := FullOptStage,
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % scalaJsDomVersion,
"com.lihaoyi" %%% "scalatags" % scalaTagsVersion,
"io.circe" %%% "circe-core" % circeVersion,
"io.circe" %%% "circe-generic" % circeVersion,
"io.circe" %%% "circe-parser" % circeVersion,
"com.github.nondeterministic" %%% "roshttp" % rosHttpVersion,
"com.timushev" %%% "scalatags-rx" % scalatagsrxVersion
),
).enablePlugins(ScalaJSPlugin, ScalaJSWeb)
.dependsOn(sharedJs)
[...]
When I build and then run my project, I have the following artifacts, needed to execute the generated JavaScript code, correctly created:
./frontend/target/scala-2.13/frontend-opt.js
./backend/target/web/classes/main/META-INF/resources/webjars/backend/0.15.0-alpha2/frontend-opt.js
./backend/target/web/public/main/frontend-opt.js
However, a problem arises when I try to update the plugin sbt-web-scalajs
to 1.1 or 1.2 as it no longer supports the isDevMode
flag used in my backend
subproject. That is, if I compile and run my project without it, only one of the three files above is generated:
./frontend/target/scala-2.13/frontend-opt.js
And my ScalaJS/JavaScript frontend fails to load, subsequently. I looked through the documentation of the sbt-web-scalajs
project, which says that all is controlled now via scalaJSStage
, but it doesn't seem to get me the required output files in the required project directories.
In other words, isDevMode
seemingly did more than just control whether fastOpt
or fullOpt
is run, and it is unclear to me how to get the old functionality back.