An sbt plugin to simplify the development and build process of full-stack Scala.js applications.
sbt-fullstack-js streamlines the integration between an sbt-based backend and a Scala.js-based frontend, often bundled with tools like Vite. It provides utilities for generating build environments and integrating npm build processes into the sbt lifecycle.
- Automated Setup: Generates
scripts/target/build-env.shto share build-time information (like Scala version and output paths) with external scripts or VS Code tasks. - Resource Integration: Automatically runs
npm run buildand includes the output in the backend's managed resources when building for production or Docker. - On-Load Hooks: Automatically triggers setup tasks when sbt starts, ensuring your development environment is always up-to-date.
Add the following to your project/plugins.sbt:
addSbtPlugin("dev.cheleb" % "sbt-fullstack-js" % "VERSION")Replace VERSION with the latest version.
In your build.sbt, enable the plugin and configure the required settings:
lazy val root = (project in file("."))
.enablePlugins(FullstackJsPlugin)
.settings(
scalaJsProject := client, // The Scala.js project
publicFolder := "public" // The folder where npm build outputs files (default: "public")
)
lazy val client = (project in file("client"))
.enablePlugins(ScalaJSPlugin)
// ... other Scala.js settingsscalaJsProject: (Required) The sbt project representing the Scala.js frontend.publicFolder: (Default:"public") The sub-directory withinresourceManagedwhere static files fromnpm run buildwill be placed.
The plugin automatically integrates with your build process. However, you can manually trigger the setup task if needed.
setup: Manually triggers the generation of the build environment script.
Run test for regular unit tests.
Run scripted for sbt script tests.
This project is licensed under the Apache-2.0 License.