I'm using resourceGenerators
sbt key to copy fastOptJs
-generated .js files when using products
, like this:
(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)
})
Running the following in sbt, I can see the path of generated file:
> 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
Similarly, I can easily see where Scala.js-generated launcher ends up:
> 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
I cannot, however, find a task/key that would point me to location of .js.map
file. I tried looking in the plugin sources, but couldn't find it. Is there any way of doing that without resorting to creating a manual mapping in build.sbt
?
Source maps generated by Scala.js always have the name of the corresponding .js file + ".map"
. So you can find the one associated with f1
with f1.getParentFile / (f1.getName + ".map")
.
Btw, no new build should use <+=
. The more understandable +=
should be used instead:
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)
}
and to avoid the in Compile
everywhere, you can use 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)
}
))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With