使用 grunt uglify 删除注释之间的代码
Remove code between comments with grunt uglify
是否可以在 javascript 中使用 grunt uglify 删除特殊注释之间的代码?
例如js代码是这样的:
源代码:
var that = this;
var x=y;
//REMOVE-BEGIN
that.someCodeToBeRemoved();
that.someMoreCodeToBeRemoved();
//REMOVE-END
that.someFunctionCall();
应该删除的内容:
//REMOVE-BEGIN
that.someCodeToBeRemoved();
that.someMoreCodeToBeRemoved();
//REMOVE-END
您可以为此使用 grunt-strip-code。
我认为 grunt uglify 做不到。
正如@marton 所说,grunt uglify 确实解析了代码并且optimize/compress/etc。你应该使用 grunt-strip-code。
查看 [[=10=] 以详细了解 uglify 的作用。
是否可以在 javascript 中使用 grunt uglify 删除特殊注释之间的代码?
例如js代码是这样的:
源代码:
var that = this;
var x=y;
//REMOVE-BEGIN
that.someCodeToBeRemoved();
that.someMoreCodeToBeRemoved();
//REMOVE-END
that.someFunctionCall();
应该删除的内容:
//REMOVE-BEGIN
that.someCodeToBeRemoved();
that.someMoreCodeToBeRemoved();
//REMOVE-END
您可以为此使用 grunt-strip-code。
我认为 grunt uglify 做不到。
正如@marton 所说,grunt uglify 确实解析了代码并且optimize/compress/etc。你应该使用 grunt-strip-code。
查看 [[=10=] 以详细了解 uglify 的作用。