javascript - uglyfy top level functions with gulp -



javascript - uglyfy top level functions with gulp -

take simple gulp illustration uglification:

gulp.task('scripts', function() { // minify , re-create javascript (except vendor scripts) homecoming gulp.src(paths.scripts) .pipe(uglify()) .pipe(concat('all.min.js')) .pipe(gulp.dest('build/js')); });

if have 2 files:

file f1.js:

function f1(){ var hello = 1; homecoming hello; }

file f2.js:

function f2(){ homecoming f1(); }

the result of task in all.min.js is:

function f1(){var n=1;return n} function f2(){return f1()}

how can uglify mangle these top level function names i.e. f1 , f2? have tried:

an uglify

return gulp.src(paths.scripts) .pipe(uglify()) .pipe(concat('all.min.js')) .pipe(gulp.dest('build/js')) .pipe(uglify());

passing mangle option

return gulp.src(paths.scripts) .pipe(uglify({mangle: true})) .pipe(concat('all.min.js')) .pipe(gulp.dest('build/js'));

passing top level option

return gulp.src(paths.scripts) .pipe(uglify({toplevel: true})) .pipe(concat('all.min.js')) .pipe(gulp.dest('build/js'));

but no effect @ all.

.pipe(uglify({mangle: {toplevel: true}}))

javascript gulp uglifyjs

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -