According to RequireJS’ website
By convention RequireJS expects a main.js file to bootstrap its module loader.
The RequireJS optimizer shouldn’t generally kick-in until it is time to perform a deployment i.e. by running the
.min.js file is found then that will be used in place of
.js. An added bonus here is that there is no change required to your html!
§Enablement and Configuration
RequireJS optimization is enabled by simply adding the plugin to your plugins.sbt file when using the
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
To add the plugin to the asset pipeline you can declare it as follows (assuming just the one plugin for the pipeline - add others into the sequence such as digest and gzip as required):
pipelineStages := Seq(rjs)
A standard build profile for the RequireJS optimizer is provided and should suffice for most projects. However please refer to the plugin’s documentation for information on how it may be configured.
Note that RequireJS performs a lot of work and while it works when executed in-JVM under Trireme, you will be best to use Node.js as the js-engine from a performance perspective. For convenience you can set the
sbt.jse.engineType property in
SBT_OPTS. For example on Unix:
export SBT_OPTS="$SBT_OPTS -Dsbt.jse.engineType=Node"
Please refer to the plugin’s documentation for information on how it may be configured.
Found an error in this documentation? The source code for this page can be found here. After reading the documentation guidelines, please feel free to contribute a pull request.