A fork (of a fork of a fork) of the seemingly abandoned sbt-uglify plugin.
To use this plugin, use the addSbtPlugin command within your project's
addSbtPlugin("org.danielnixon" % "sbt-uglify" % "1.0.7")
Your project's build file also needs to enable sbt-web plugins. For example, with build.sbt:
lazy val root = (project in file(".")).enablePlugins(SbtWeb)
As with all sbt-web asset pipeline plugins you must declare their order of execution:
pipelineStages := Seq(uglify)
A standard build profile for the Uglify optimizer is provided which will mangle variables for obfuscation and
compression. Each input
.js file found in your assets folders will have a corresponding
.min.js file and source maps will also be generated.
If you wish to limit or extend what is uglified then you can use filters:
includeFilter in uglify := GlobFilter("myjs/*.js"),
...where the above will include only those files under the
excludeFilter is also available to the
uglify scope and defaults to excluding the public folder and extracted Webjars.
If you wish to change how files are mapped from input to output, you can change the
uglifyOps setting to point at another grouping.
The default ops takes a source file and produces minified file and source map:
UglifyKeys.uglifyOps := UglifyOps.singleFileWithSourceMapOut
This ops takes a source file and produces minified file only (no source map):
UglifyKeys.uglifyOps := UglifyOps.singleFile
This ops takes a source file and source map and produces minified file and combined source map. Your includeFilter must include source map files for this to work:
UglifyKeys.uglifyOps := UglifyOps.singleFileWithSourceMapInAndOut
You are able to use and/or customize settings already made, and add your own. Here are a list of relevant settings and their meanings (please refer to the UglifyJS documentation for details on the options):
|Specifies comments handling.
|Enables compression. Set true to compress.
|A sequence of options for compression such as hoist_vars, if_return etc.
|Enclose in one big function.
|Include the content of source files in the source map as the sourcesContent property.
|Enables name mangling.
|Options for mangling such as sort, topLevel etc.
|Any preamble to include at the start of the output.
|Reserved names to exclude from mangling.
|A function defining how to combine input files into output files.
© Typesafe Inc., 2014