A somewhat advanced template for a Scala.js project with DOM and jQuery.
The project is in no way a minimal one, as it aims to showcase everything one would probably end up doing in a real-world app.
The project doesn't contain any UI components framework.
- Shows mapping code in both directions: Scala.js code accessing JavaScript code and vice versa.
- Shows using libraries from WebJars and from external JavaScript files.
- Shows passing parameters to build and generating resources from templates.
- Shows using utility Scala code in SBT build task.
- Includes coursier, wartremover and scalafmt.
Build target folder is bin
in project root. That's where all of the resources are copied to and where the fastOptJs
/fullOptJS
output is directed.
The version
parameter is optional, it defaults to the version
setting in build.sbt
.
/build-dev.sh -Dversion="0.1.0"
or
/build-release.sh -Dversion="0.1.0"
Open /bin/index.html
to see the result.
Start SBT with sbt -mem 2000 -Dversion="0.1.0"
. The memory setting here prevents SBT from crashing with out of memory exception after a dozen rebuilds in interactive mode.
- Use
release
ordev
commands to clean, build and collect resources. - Use
buildRelease
orbuildDev
to build and collect resources. - Use
fastOptJS
orfullOptJS
as you normally would with any Scala.js project to just build main javascript files.
/bin
– this is where all build files go. The directory is created by build commands and is deleted completely byclean
command./project
– a standard SBT project directory, which containsBuildUtils.scala
, that does file manipulation during build./resources
– contains static resources (like css and images) and templates (html) that get processed by build logic./src/main/resources/
– the standard directory for js libraries. Seejs/example.js
there.