Skip to content

Commit

Permalink
0.3.2: only copy important artifacts to webjar crossTarget for scalaJ…
Browse files Browse the repository at this point in the history
…SBundler
  • Loading branch information
lhns committed Jun 2, 2020
1 parent dab9cde commit 54a4ab8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -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")),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)
}

0 comments on commit 54a4ab8

Please sign in to comment.