Skip to content

Commit

Permalink
Add ga(...) as reserved word for uglify (#483)
Browse files Browse the repository at this point in the history
* Bump gulp-uglify to 3.0.1. Add ga as reserved word for uglify. Fix mock ga

* Self-review fixes
  • Loading branch information
ArtemijRodionov authored and duker33 committed Aug 6, 2018
1 parent f0e50b7 commit cd0b83b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
10 changes: 7 additions & 3 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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));
}

Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 2 additions & 7 deletions templates/layout/google_tag_manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,15 @@
{% else %}
{% if is_head_tag %}
<script>
var gaContext = (function() {
var ga = (function() {
var results = [];

var fn = function(action, params) {
results.push([action, params]);
console.log('GA:', JSON.stringify([action, params]));
};

return {
fn: fn,
results: results,
}
return fn;
}());
var ga = gaContext.fn;

window.dataLayer = (function() {
var results = [];
Expand Down

0 comments on commit cd0b83b

Please sign in to comment.