Requires: WebServicePlugin
&& NodeJsPlugin
(node plugin doc)
The sbt-webapp
is a superset of the WebServicePlugin
which adds support for managing a Node.js build from SBT. You enable the plugin for your project. In build.sbt
:
val myProject = project.in(file(".")).enablePlugins(WebappPlugin)
Note: you do not need to import anything as WebappPlugin
is automatically imported when you add the plugin.
By default, the sbt-webapp
plugin sets the sbt-node-js
settings for the webapp root directory and build directory. They are:
nodeProjectDirectory -> [project]/webapp
nodeProjectTarget -> [project]/public
Note: these files are relative to your project, so they will be at the same level as src
and target
in your project directory.
Additionally, the sbt-webapp
plugin adds the buildDir
to the mappings.in(Universal)
setting to ensure the buildDir
(default is public
) is deployed along with the application.
You can change any of the settings for sbt-node-js
and sbt-deploy
plugins in the following way:
// in build.sbt
enablePlugins(WebappPlugin)
nodeProjectDir.in(Npm) := file("clientapp")
nodeProjectTarget.in(Npm) := file("client-build")
Note: if you change nodeProjectDirectory
, the mappings.in(Universal)
will automatically use the overridden value and package it up during deploy.
The required WebServicePlugin
includes sbt-revolver
. For development, you can run the service layer of the web application via:
sbt
> reStart