How can I include individual javascript files in jsDependencies when using ScalaJSPlugin with SBT?

885 Views Asked by At

I'm trying use 'ProvidedJS' like this:

jsDependencies ++= Seq(
  ...,
  ProvidedJS / "my-script.js"
)

and put the javascript file under src/main/resources

Getting the following error:

(client/compile:scalaJSPreLinkClasspath)
org.scalajs.core.tools.classpath.JSLibResolveException: 
Some references to JS libraries could not be resolved:
- Missing JS library: my-script.js
2

There are 2 best solutions below

2
On

just put it into ./src/main/resources/my-script.js

0
On
  1. Add addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") and addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0") to plugins.sbt

  2. Add jsDependencies += ProvidedJS / "my-script.js" to settings project in build.sbt

  3. Put your file to /src/main/resources/my-script.js

  4. run sbt clean compile fastOptJS

  5. Search your file <project_dir>/target/scala-2.12/<your_project>_js-jsdeps.js