Search code examples
playframeworkplayframework-2.0uglifyjsuglifyjs2xsbt-web-plugin

sbt-uglify compressOptions not taking?


I have been trying to add in sbt-uglify, which has worked out through trial and error. I find the documentation lacking and Google results not good. This plugin is based on UglifyJS.

The issue I am having is the fact that it drops unreachable code and unused functions/variables. This will be well enough if this was my code but I have to maintain legacy JS and can't have side effects of dropped stuff.

The code I used is Seq("unused: false", "dead_code: false") but have also tried Seq("unused: false, dead_code: false")

If someone knows if I am missing something please let me know.

Helpful Links: https://github.com/sbt/sbt-uglify

Here is a sample project if need be, but it is not of my own: https://github.com/nonameplum/play-uglify-test

Thanks!


Solution

  • Use Seq("unused=false", "dead_code=false")

    The setting is passed directly to UglifyJS2 as command-line arguments. Uglify expects options in the form foo=bar according to their documentation:

    https://github.com/mishoo/UglifyJS2#compressor-options