Plugin

sjsls also has a mill plugin (requires mill > 1.1.4). This plugin aims to make it very simple to develop and deploy a scala-js project.

build.mill

//| mill-version: 1.1.5
//| mvnDeps:
//| - io.github.quafadas:sjsls_plugin_mill1_3.8:0.14.5

package.mill

package build.example

import mill.*, scalalib.*, scalajslib.*
import mill.scalajslib.api.*
import io.github.quafadas.ScalaJsWebAppModule

object `package` extends ScalaJsWebAppModule:
  def scalaVersion = "3.8.2"

  def mvnDeps = Seq(
    mvn"io.github.nguyenyou::webawesome-laminar::3.0.0"
  )

  override def moduleSplitStyle = ModuleSplitStyle.SmallModulesFor(
    "mathlify",
    "mathlify.example"
  )

  override def scalaJSImportMap = Seq(
    ESModuleImportMapping.Prefix("@awesome.me/webawesome/dist/", "https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3.4.0/dist-cdn/")
  )

  override def externalStylesheets = Seq(
    "https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3.4.0/dist-cdn/styles/webawesome.css"
  )
end `package`

This build encapsulates the standard ScalaJsWebAppModule workflow:

What ScalaJsWebAppModule provides

ScalaJsWebAppModule combines the live-reload server from ScalaJsRefreshModule with the in-memory content hashing support from InMemoryFastLinkHashScalaJSModule.

In practice that means:

Lower-level plugin: ScalaJsRefreshModule

If you only want the development server and generated index.html, ScalaJsRefreshModule is the smaller building block.

It provides:

ScalaJsWebAppModule builds on top of it by adding in-memory content hashing and assembleSite for a static output directory.

Development Workflow

mill -w example.serve

Page reload is very fast.

Production Workflow

The assembleSite command:

You can then serve that output locally with the command printed by mill show example.serveCommand.