2

I'm trying to write an app that's part ScalaJS and part Play framework. I'm using the ScalaJS bundler. It's bundling my JavaScript fine and I can see the resulting files where they are supposed to go.

enter image description here

But I noticed that only client-jsdeps.js and client-fastopt.js are available to the app. The reason for that is that their are the only files that are copied to the path server/target/web/public/main. I have looked everywhere I could think, sbt build files, config files, everywhere, and I could not find why those files are copied over and no other. I'd like the -bundle files to be copied instead. Where is that setting?

It is worth noting that the two files that are packaged with the app do not appear in the user-editable path, server/public/js, they are copied directly to the WAR file and therefore visible in the target directory.

eje211
  • 2,385
  • 3
  • 28
  • 44

1 Answers1

3

From the documentation:

For sbt-web integration use the sbt-web-scalajs-bundler plugin instead of sbt-scalajs-bundler:

addSbtPlugin("ch.epfl.scala" % "sbt-web-scalajs-bundler" % "0.13.1")

Then, enable the WebScalaJSBundlerPlugin on the project that uses sbt-web:

lazy val server = project
  .settings(
    scalaJSProjects := Seq(client),
    pipelineStages in Assets := Seq(scalaJSPipeline)
  )
  .enablePlugins(WebScalaJSBundlerPlugin)

lazy val client = project.enablePlugins(ScalaJSBundlerPlugin, ScalaJSWeb)

You also need to setup the ScalaJSBundlerPlugin on the Scala.js project, as described in the preceding section, and the sbt-web-scalajs plugins as described in their documentation.

The WebScalaJSBundlerPlugin plugin automatically configures the scalaJSPipeline task to use the bundles rather than the output of the Scala.js compilation.

You can see a complete example here.


Do you follow that guide?

Julien Richard-Foy
  • 9,634
  • 2
  • 36
  • 42
  • 1
    I had found it, but I had problems with parts of it earlier on the page and had not gotten to that part. Also, there are many guides, but that is the only one that mentions `WebScalaJsBundlePlugin`, so it was easy to overlook. I found it now and the bundles are included. Thanks! – eje211 Sep 12 '18 at 14:22