From 5c3839d5c5cf8385e65fecfb3c7c69ae0058603a Mon Sep 17 00:00:00 2001 From: Vincent Munier Date: Sat, 3 Jul 2021 23:44:29 +0100 Subject: [PATCH] Make it compatible with sbt-web-scalajs v1.2.0 for main.js (#55) * Make it compatible with sbt-web-scalajs v1.2.0 for main.js * Upgrade to latest libraries * Update README.md --- README.md | 9 +-------- build.sbt | 4 ++-- project/build.properties | 2 +- src/main/twirl/scalajs/selectScript.scala.html | 9 ++++++++- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index dbed05d..414c6b7 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,11 @@ Small library which provides a way to link Scala.js output to HTML templating en [twirl](https://github.com/playframework/twirl), [scalatags](https://github.com/lihaoyi/scalatags) or even standard scala string interpolation. - -## When using sbt-web-scalajs `v1.2.0` or higher - -*scalajs-scripts is deprecated when using sbt-web-scalajs `v1.2.0` or higher. The recommended approach is to create a template helper in the project itself. Example of a `findScript.scala.html` template in [Play](https://github.com/vmunier/play-scalajs.g8/blob/856e70e60f518db27cd8db524abf0bed1d0fc59d/src/main/g8/server/app/views/findScript.scala.html) and [Akka HTTP](https://github.com/vmunier/akka-http-scalajs.g8/blob/961276766e4c69caf9ad6aee9a14b283cc2bc946/src/main/g8/server/src/main/twirl/%24package%24/findScript.scala.html).* - -## When using sbt-web-scalajs `v1.1.0` or lower - ## Setup Add the library to `build.sbt`: ``` -libraryDependencies += "com.vmunier" %% "scalajs-scripts" % "1.1.4" +libraryDependencies += "com.vmunier" %% "scalajs-scripts" % "1.2.0" ``` ## Integration with Twirl diff --git a/build.sbt b/build.sbt index 4ffa756..0e48395 100644 --- a/build.sbt +++ b/build.sbt @@ -14,8 +14,8 @@ inThisBuild(List( )) name := "scalajs-scripts" -scalaVersion := "2.13.2" -crossScalaVersions := Seq("2.12.11", scalaVersion.value) +scalaVersion := "2.13.6" +crossScalaVersions := Seq("2.12.14", scalaVersion.value) enablePlugins(SbtTwirl) diff --git a/project/build.properties b/project/build.properties index 67d27a1..9edb75b 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.3 +sbt.version=1.5.4 diff --git a/src/main/twirl/scalajs/selectScript.scala.html b/src/main/twirl/scalajs/selectScript.scala.html index 178aab5..2b1196f 100644 --- a/src/main/twirl/scalajs/selectScript.scala.html +++ b/src/main/twirl/scalajs/selectScript.scala.html @@ -6,7 +6,14 @@ @defining(s"${projectName.toLowerCase}") { name => @{ - val possibleArtifacts = Seq(s"$name-opt-bundle.js", s"$name-fastopt-bundle.js", s"$name-opt/main.js", s"$name-fastopt/main.js") + val possibleArtifacts = Seq( + s"$name-opt-bundle.js", + s"$name-fastopt-bundle.js", + s"$name-opt/main.js", + s"$name-fastopt/main.js", + s"$name-opt.js", + s"$name-fastopt.js" + ) possibleArtifacts.find(resourceExists).map(filename => jsScript(assets(filename), htmlAttributes)) } }