Scala.js project structure

Scala.js comes with an sbt plugin that facilitates compiling, running and testing with Scala.js. For a quick start, have a look at our basic tutorial.

Load the sbt plugin (project/plugins.sbt)

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.17.0")

Enable the plugin on the sbt project (build.sbt):

lazy val root = project
  .in(file("."))
  .enablePlugins(ScalaJSPlugin)
  .settings(
    // for an application with a main method
    scalaJSUseMainModuleInitializer := true,
  )

If you are using a Build.scala definition, import the following:

import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._

Next we’ll look into the building process in more detail.