How to quickly and conveniently disable all console.log statements in my code?

后端 未结 28 2499
深忆病人
深忆病人 2020-11-22 16:48

Is there any way to turn off all console.log statements in my JavaScript code, for testing purposes?

28条回答
  •  难免孤独
    2020-11-22 17:26

    If you're using gulp, then you can use this plugin:

    Install this plugin with the command:

    npm install gulp-remove-logging

    Next, add this line to your gulpfile:

    var gulp_remove_logging = require("gulp-remove-logging");

    Lastly, add the configuration settings (see below) to your gulpfile.

    Task Configuration

    gulp.task("remove_logging", function() {
         return gulp.src("src/javascripts/**/*.js")
        .pipe(
          gulp_remove_logging()
        )
        .pipe(
          gulp.dest(
            "build/javascripts/"
          )
        ); });
    

提交回复
热议问题