我使用resourceGenerators sbt键在使用products时复制fastOptJs-generated .js文件,如下所示:
(resourceGenerators in Compile) <+=
(fastOptJS in Compile in frontend, packageScalaJSLauncher in Compile in frontend, packageJSDependencies in Compile in frontend)
.map((f1, f2, f3) => {
Seq(f1.data, f2.data, f3)
})在sbt中运行以下命令,我可以看到生成文件的路径:
> show frontend/fastOptJS
[info] Attributed(/some/path/frontend/target/scala-2.11/frontend-fastopt.js)
[success] Total time: 0 s, completed Mar 12, 2016 1:59:22 PM类似地,我可以很容易地看到Scala.js生成的启动程序在哪里结束:
> show frontend/packageScalaJSLauncher
[info] Attributed(/some/path/frontend/target/scala-2.11/frontend-launcher.js)
[success] Total time: 0 s, completed Mar 12, 2016 2:00:10 PM但是,我找不到一个任务/键来指向.js.map文件的位置。我试着查找插件的来源,但找不到。有没有办法做到这一点而不诉诸于在build.sbt中创建手动映射
发布于 2016-03-12 14:51:55
Scala.js生成的源映射始终具有相应的.js文件+ ".map"的名称。因此,您可以找到与f1相关的f1.getParentFile / (f1.getName + ".map")。
顺便说一下,任何新的构建都不应该使用<+=。应该使用更容易理解的+=:
resourceGenerators in Compile += Def.task {
val f1 = (fastOptJS in Compile in frontend).value.data
val f1SourceMap = f1.getParentFile / (f1.getName + ".map")
val f2 = (packageScalaJSLauncher in Compile in frontend).value.data
val f3 = (packageJSDependencies in Compile in frontend).value
Seq(f1, f1SourceMap, f2, f3)
}为了避免任何地方的in Compile,您可以使用inConfig(Compile)
inConfig(Compile)(Seq(
resourceGenerators += Def.task {
val f1 = (fastOptJS in frontend).value.data
val f1SourceMap = f1.getParentFile / (f1.getName + ".map")
val f2 = (packageScalaJSLauncher in frontend).value.data
val f3 = (packageJSDependencies in frontend).value
Seq(f1, f1SourceMap, f2, f3)
}
))https://stackoverflow.com/questions/35958078
复制相似问题