From cd0b83be5cc248950f8ad46607e010db22d3effe Mon Sep 17 00:00:00 2001 From: Artemiy Date: Mon, 6 Aug 2018 22:15:46 +0300 Subject: [PATCH] Add ga(...) as reserved word for uglify (#483) * Bump gulp-uglify to 3.0.1. Add ga as reserved word for uglify. Fix mock ga * Self-review fixes --- gulpfile.babel.js | 10 +++++++--- package.json | 2 +- templates/layout/google_tag_manager.html | 9 ++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 6b5919a5..3544eeb7 100755 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -9,7 +9,6 @@ import sequence from 'run-sequence'; const $ = require('gulp-load-plugins')(); const flexibility = require('postcss-flexibility')(); -const spawnSync = require('child_process').spawnSync; console.log(` You've seen warning because of deprecated deps during npm install. @@ -239,7 +238,7 @@ function vendorJS(source, destination, fileName) { .pipe($.changed(path.build.js, { extension: '.js' })) .pipe($.concat(`${fileName}.js`)) .pipe($.rename({ suffix: '.min' })) - .pipe($.uglify()) + .pipe($.uglify({ mangle: { reserved: ['ga'] } })) .pipe(gulp.dest(destination)); } @@ -254,7 +253,12 @@ function appJS(source, destination, fileName) { compact: false, })) .pipe($.rename({ suffix: '.min' })) - .pipe($.if(env.production, $.uglify())) + .pipe($.if( + env.production, + $.uglify({ + mangle: { reserved: ['ga'] }, + }) + )) .pipe($.if(env.development, $.sourcemaps.write('.'))) .pipe(gulp.dest(destination)) .pipe($.livereload()); diff --git a/package.json b/package.json index 80563ee3..5eeabf6b 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "gulp-postcss": "^6.3.0", "gulp-rename": "^1.2.2", "gulp-sourcemaps": "^2.4.0", - "gulp-uglify": "^2.1.0", + "gulp-uglify": "^3.0.1", "gulp.spritesmith": "^6.3.0", "less-plugin-glob": "^2.0.0", "postcss-csso": "^2.0.0", diff --git a/templates/layout/google_tag_manager.html b/templates/layout/google_tag_manager.html index 6200d498..08308b4a 100644 --- a/templates/layout/google_tag_manager.html +++ b/templates/layout/google_tag_manager.html @@ -24,20 +24,15 @@ {% else %} {% if is_head_tag %}