在将ScalaJSPlugin与SBT一起使用时,如何在jsDependencies中包含单个javascript文件?

时间:2015-06-24 19:30:50

标签: sbt scala.js

我正在尝试使用'providedJS'这样:

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

并将javascript文件放在src/main/resources

收到以下错误:

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

3 个答案:

答案 0 :(得分:0)

将其放入./src/main/resources/my-script.js

答案 1 :(得分:0)

  1. addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0") 添加到 plugins.sbt

  2. jsDependencies += ProvidedJS / "my-script.js" 添加到 build.sbt

    中的设置项目
  3. 把你的文件放到/src/main/resources/my-script.js

  4. 运行sbt clean compile fastOptJS

  5. 搜索您的文件 <project_dir>/target/scala-2.12/<your_project>_js-jsdeps.js

答案 2 :(得分:-1)

根据http://www.scala-js.org/doc/project/dependencies.html,您的代码段是正确的 - 但是,值得检查构建的其他部分,例如: https://groups.google.com/forum/#!topic/scala-js/8JzjI5MK4kI