Using sbt-web-scalajs with single-project build
Krever opened this issue · 3 comments
Hi,
I think it is currently not possible to use sbt-web-scalajs with single-project build. What I mean, is to have scalajs sources in our sbt-web project. Currently we need to have at least two projects: "sbt-web one" and "scalajs one".
If I'm wrong or there is a good reason for such behaviour please tell me!
Thanks
Hi,
Indeed, it is currently not possible to use sbt-web-scalajs within a single-project build.
You cannot do the following:
lazy val client: Project = project.settings(
// self referencing the client project would cause an infinite loop when running compile
scalaJSProjects := Seq(client),
pipelineStages in Assets := Seq(scalaJSPipeline)
).enablePlugins(ScalaJSPlugin, ScalaJSWeb, SbtWeb)
The main goal of sbt-web-scalajs is to collect the Scala.js output files (*-opt.js
, *-launcher.js
, sourcemap files) using SbtWeb pipelines, so that a Server could send those files down to a browser.
Out of curiosity, why would you like to use sbt-web-scalajs without any server?
To generate fully static site and serve it outside of a project with some external server, e.g. Apache HTTP, nginx, Amazon S3, etc.
@Krever Yes it works:
lazy val myProject = crossProject
.crossType(CrossType.Pure)
lazy val myProjectJVM = myProject.jvm
.enablePlugins(SbtWeb)
.settings(
WebKeys.packagePrefix in Assets := "public/",
managedClasspath in Runtime += (packageBin in Assets).value,
scalaJSProjects := Seq(myProjectJS),
pipelineStages in Assets := Seq(scalaJSPipeline)
)
lazy val myProjectJS = myProject.js
.enablePlugins(ScalaJSPlugin, ScalaJSWeb)
.settings(scalaJSUseMainModuleInitializer := true)