I'm working on a Scala.js cross project where the jvm
folder represents my server application and js
represents my scala.js code.
Whenever i compile my scala.js code via sbt crossJS/fastOptJS
the compiled JS ends up in ./js/target/scala-2.11/web-fastopt.js
.
I need to have this compiled JS file accessible in the resources of the server project in the jvm
folder, so i can server it through my web application. I think i have to do something with artifactPath
but i can't seem to get any results from my experiments thus far.
You can configure the Scala.js SBT plugin to output the JavaScript file in folder of your choosing. For example like this:
This will also store -jsdeps.js and .js.map files in the same folder, in case you want to use those in your web app.
For a more complete example, check out this tutorial which addresses many other issues of creating a more complex Scala.js application.
You can simply set the
artifactPath
of thefastOptJS
task (or thefullOptJS
task) to the (managed) resources directory of your JVM project:This will put it in the directory, if the you run the fastOptJS task. However, it will not be included in sbt's
resources
task and it will not automatically be triggered, if you launch your server. Therefore:A couple of notes:
Setting thecrossTarget
, as in @ochrons' answer will also output all the.class
and.sjsir
files in the resource directory.js
project, rather than directly placing it in the JVM project. Useful if you have multiple JVM projects).Or simply:
Compare to gzm0's solution you are not re