Front-end compression packaging, can you remove the console and so on, find the answer, but not ah?

can pack, but console.log can"t go.

gulp.task("agency:build", ["agency:cache-templates"], function (cb) {
    agencySource.js.src.push(agencySource.build.cache + "/app.js");
    pump(
        [
            gulp
                .src(agencySource.js.src)
                .pipe(envify({ NODE_ENV: "production" }))
                .pipe(stripDebug())
                .pipe(ngAnnotate())
                .pipe(babel())
                .pipe(concat("app.js")),
                
                //process.env.NODE_ENV
            uglify({ drop_console: true}),
            gulp.dest(agencySource.build.cache)
            // .pipe(concat("app.js"))
            // .pipe(gulp.dest(agencySource.build.cache))
        ],
        cb
    );
});

found part of the answer, but the effect is not complete, only part of the console can be removed

uglify({
  compress: {
    warnings: false,
    drop_console: true,  //  console
    drop_debugger: true  //  debugger
  }
})
console.log1200800

`window.console.log = function() {}`console

I hope I can optimize one more. How to get rid of the extra console

ask the bosses to save a wave! Thank you

Jul.16,2021

if you remember correctly, drop_console in compress , of course you can't get rid of it.

it is recommended that you read the document carefully.


in webpack.prod.conf.js file

new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
        /**/
        drop_debugger: true,
        drop_console: true,
        pure_funcs: ['console.log']
      },
      sourceMap: false
    })

you are using gulp, to install the gulp-uglify plug-in;

uglify({
  compress: {
    warnings: false,
    drop_console: true,  //  console
    drop_debugger: true  //  debugger
  }
})

http://www.hangzhoufe.com/top.


< H1 > perfect solution < / H1 >
var es = require("event-stream");
var gulp = require("gulp");
var pump = require("pump");
var babel = require("gulp-babel");
var ngAnnotate = require("gulp-ng-annotate");

gulp.task("agency:prodjs", function (cb) {
    pump(
        [ es
        .merge(gulp.src(agencySource.js.src))
            .pipe(ngAnnotate())
            .pipe(babel())
        .pipe(concat("app.js")),
        uglify({
                compress: {
                    warnings: false,
                    drop_console: true, //  console
                    drop_debugger: true //  debugger
                }
            }),
            gulp.dest(agencySource.build.cache)
        ],
        cb
    );
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37c6e-4064a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37c6e-4064a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?