Skip to content

Commit

Permalink
Make it compatible with sbt-web-scalajs v1.2.0 for main.js (#55)
Browse files Browse the repository at this point in the history
* Make it compatible with sbt-web-scalajs v1.2.0 for main.js

* Upgrade to latest libraries

* Update README.md
  • Loading branch information
vmunier authored Jul 3, 2021
1 parent 86ce13d commit 5c3839d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.3
sbt.version=1.5.4
9 changes: 8 additions & 1 deletion src/main/twirl/scalajs/selectScript.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

0 comments on commit 5c3839d

Please sign in to comment.