Search code examples
javascriptuglifyjs

Remove code between comments with grunt uglify


Is it possible to remove code between special comments with grunt uglify in javascript?

For example js code like this:

Source code:

var that = this;
var x=y;
//REMOVE-BEGIN
that.someCodeToBeRemoved();
that.someMoreCodeToBeRemoved();
//REMOVE-END
that.someFunctionCall();

What should be removed:

//REMOVE-BEGIN
that.someCodeToBeRemoved();
that.someMoreCodeToBeRemoved();
//REMOVE-END

Solution

  • You can use grunt-strip-code for this.

    I don't think grunt uglify can do it.