From 54a4ab8b0858a5da85e778f60d65f254ea8fac4d Mon Sep 17 00:00:00 2001 From: Pierre Kisters Date: Tue, 2 Jun 2020 15:41:43 +0200 Subject: [PATCH] 0.3.2: only copy important artifacts to webjar crossTarget for scalaJSBundler --- build.sbt | 2 +- .../scalajs/webjar/ScalaJSBundlerWebjarPlugin.scala | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 46396ad..21d1871 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ lazy val commonSettings: Seq[Setting[_]] = Seq( organization := "de.lolhens", - version := "0.3.1-SNAPSHOT", + version := "0.3.2-SNAPSHOT", licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")), diff --git a/sbt-scalajs-bundler-webjar/src/main/scala/de/lolhens/sbt/scalajs/webjar/ScalaJSBundlerWebjarPlugin.scala b/sbt-scalajs-bundler-webjar/src/main/scala/de/lolhens/sbt/scalajs/webjar/ScalaJSBundlerWebjarPlugin.scala index f883cbc..d42f75a 100644 --- a/sbt-scalajs-bundler-webjar/src/main/scala/de/lolhens/sbt/scalajs/webjar/ScalaJSBundlerWebjarPlugin.scala +++ b/sbt-scalajs-bundler-webjar/src/main/scala/de/lolhens/sbt/scalajs/webjar/ScalaJSBundlerWebjarPlugin.scala @@ -12,17 +12,22 @@ object ScalaJSBundlerWebjarPlugin extends AutoPlugin { override lazy val projectSettings: Seq[Setting[_]] = Seq( - Compile / npmUpdate / crossTarget := (Compile / webjarArtifacts / crossTarget).value, - Compile / webjarMainResourceName := stagedOptJS(Compile / _ / artifactPath).value.name.stripSuffix(".js") + "-bundle.js", Compile / webjarArtifacts := { val attributedFiles = stagedOptJS(Compile / _ / webpack).value + val target = (Compile / webjarArtifacts / crossTarget).value - Seq( + val artifacts = Seq( attributedFiles.find(_.metadata.get(BundlerFileTypeAttr).exists(_ == BundlerFileType.ApplicationBundle)).map(_.data), attributedFiles.find(_.metadata.get(BundlerFileTypeAttr).exists(_ == BundlerFileType.Asset)).map(_.data), - ).flatMap(_.toList) + ) + .flatMap(_.toList) + .map(file => (file, target / file.name)) + + IO.copy(artifacts) + + artifacts.map(_._2) } ) }