Search code examples
scalasbtscala.jsscalajs-bundlerscalably-typed

SBT: How to use `fastOptJS::webpack` in `build.sbt`?


I have in my build.sbt a copy task, like:

copyTask := {
  val r = (Compile / fastOptJS).value
  val destinationPath = file("docs/_includes/scala-js-tutorial-fastopt.js").toPath
  java.nio.file.Files.copy(r.data.toPath, destinationPath, StandardCopyOption.REPLACE_EXISTING)
}

The idea is to run ~copyTask so the changes are automatically in my HTML page.

That works until I used the ScalaJSBundlerPlugin.

Now the task is fastOptJS::webpack.

The question is how to adjust my copy task?

I tried without success:

 val r = (Compile / fastOptJS::webpack).value

and

 val r = (Compile / (fastOptJS::webpack)).value

Solution

  • The task fastOptJS::webpack actually refers to the task webpack scoped within fastOptJS, so the :: is an actual separator, which you would translate to another / in the build.sbt, as follows:

    val r = (Compile / fastOptJS / webpack).value