§Using Google Closure Compiler
app/assets will be parsed by Google Closure compiler, checked for errors and dependencies and minified if activated in the build configuration.
compile command, as well as automatically when modified. Error are shown in the browser just like any other compilation error.
A minified file is also generated, where
.js is replaced by
.min.js. In our example, it would be
test.min.js. If you want to use the minified file instead of the regular file, you need to change the script source attribute in your HTML.
build.sbt by overriding the
For example, to compile only
.js file from the
The default definition is:
ClosureCompiler compilation can be configured in your project’s
build.sbt file. There are several currently supported options:
- advancedOptimizations Achieves extra compressions by being more aggressive in the ways that it transforms code and renames symbols. However, this more aggressive approach means that you must take greater care when you use ADVANCED_OPTIMIZATIONS to ensure that the output code works the same way as the input code.
- checkCaja Checks Caja control structures.
- checkControlStructures Checks for invalid control structures.
- checkTypes Checks for invalid types.
- checkSymbols Checks for invalid symbols.
- ecmascript5 Sets the input- and output-language to the newer ECMAScript version 5. Might break code on older browsers.
closureCompilerOptions += "ecmascript5"
Next: Using require.js to manage dependencies
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. Have questions or advice to share? Go to our community forums to start a conversation with the community.