Pratheep
Pratheep

Reputation: 1076

Passing UglifyJS options to Grunt Uglify

I'm trying to use grunt-contrib-uglify with Grunt, which uses UglifyJS under the hood. Grunt-contrib-uglify has its own options that we may use, as below;

uglify: {
  dist: {
    options: {
      mangle: false
    },
    files: {
      'dist/build.min.js': ['dist/build.js']
    }
  }
},

However I need better customization that UglifyJS provides. But I can't figure out how to use them with grunt-contrib-uglify, The Github page just tells to refer to UglifyJS documentation for advanced configuration. Would appreciate if someone can point out how to use UglifyJS options. Thanks.

Upvotes: 2

Views: 682

Answers (1)

Chris Tonkinson
Chris Tonkinson

Reputation: 14459

It's a tricky one, and I lost some time to this as well.

Read closely under the grunt-contrib-uglify compress option documentation, and it says:

Turn on or off source compression with default options. If an Object is specified, it is passed as options to UglifyJS.Compressor().

Said another way, you can directly set UglifyJS options via the compress option in your task.

Upvotes: 1

Related Questions