What is wrong with s is undefined after compressing with gulp uglify?

there is no problem with using the original file, and using js compressed with gulp will report this error.

clipboard.png

gulp is configured as follows:

gulp.task ("bab", function () {

)
var path = "./cdn/public_html/4.0/js/member_activity.js"
var index = path.lastIndexOf("/")
var ToPath = path.slice(0, index);
return gulp.src(path)
    .pipe(sourcemaps.init())
    .pipe(babel({
        presets: ["es2015"]
    }))
    .pipe(uglify(
        {
            compress:{
                drop_console: true,  //  console
                drop_debugger: true  //  debugger
            }
        }
    ))
    .pipe(rename({
        extname: ".min.js"
    }))
    .pipe(sourcemaps.write("./cdn/public_html/4.0/js/map"))
    .pipe(gulp.dest("./cdn/public_html/4.0/js"));

})

I would also like to ask an experienced boss to advise us what will lead to this operation.

Jul.14,2021

does member_activity.js depend on other files?
if so. It needs to be packed together.


the variable name will be changed during compression. For example, if you have a variable name that is very descriptive but very long, called iKnowWhatYouDoInLastSummer , then you will try to change it to a during compression, thus achieving a compression ratio of 26-> 1.

but you may have many files that depend on each other, and compressing only one of them will break the dependence of other files on it, resulting in the problem of "some variable is undefined". (of course, it could be other problems, but from your description, this kind of problem is more likely.)

there are two solutions:

  1. use webpack or similar tools to merge JS, to rename dependencies and dependencies together
  2. use mangle:false (other configuration items may also be forgotten, rarely used) without changing the quantity name

https://www.npmjs.com/package.

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-1b35ca7-34370.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-1b35ca7-34370.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?