From fbcafefd5b9f9f0ff81dc49cafa8f218659409fd Mon Sep 17 00:00:00 2001 From: Joost van der Laan Date: Tue, 2 Feb 2016 21:52:58 +0100 Subject: [PATCH 1/3] minify styles & scripts which are placed inline. For example the Google Analytics code will be minified. --- gulpfile.babel.js | 12 ++++++++++++ package.json | 1 + 2 files changed, 13 insertions(+) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index a4965ac6c..d3ec9f87f 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -154,6 +154,18 @@ gulp.task('html', () => { removeStyleLinkTypeAttributes: true, removeOptionalTags: true }))) + .pipe($.if('*.html', $.minifyInline({ + js: { + output: { + comments: true + } + }, + jsSelector: 'script[type!="text/x-handlebars-template"]', + css: { + keepSpecialComments: 1 + }, + cssSelector: 'style[do-not-minify!="true"]' + }))) // Output files .pipe($.if('*.html', $.size({title: 'html', showFiles: true}))) .pipe(gulp.dest('dist')); diff --git a/package.json b/package.json index c401f4050..06ba3c723 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "gulp-if": "^2.0.0", "gulp-imagemin": "^2.0.0", "gulp-load-plugins": "^1.0.0", + "gulp-minify-inline": "^0.1.1", "gulp-newer": "^1.0.0", "gulp-sass": "^2.0.0", "gulp-size": "^2.0.0", From 76af76f40aad822fb4f7079e46ac6a8eec653f46 Mon Sep 17 00:00:00 2001 From: Joost van der Laan Date: Wed, 3 Feb 2016 19:36:17 +0100 Subject: [PATCH 2/3] Strip JS comments and use better CSS attribute name --- gulpfile.babel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index d3ec9f87f..4650218a6 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -157,14 +157,14 @@ gulp.task('html', () => { .pipe($.if('*.html', $.minifyInline({ js: { output: { - comments: true + comments: false } }, jsSelector: 'script[type!="text/x-handlebars-template"]', css: { keepSpecialComments: 1 }, - cssSelector: 'style[do-not-minify!="true"]' + cssSelector: 'style[data-do-not-minify!="true"]' }))) // Output files .pipe($.if('*.html', $.size({title: 'html', showFiles: true}))) From 278c4b747beba407c4c43a249c015c30fe93896b Mon Sep 17 00:00:00 2001 From: Joost van der Laan Date: Wed, 3 Feb 2016 20:50:18 +0100 Subject: [PATCH 3/3] Remove handlebars exclusion, simply because there is no handlebars used in Web Starter Kit --- gulpfile.babel.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 4650218a6..767f0718b 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -160,7 +160,6 @@ gulp.task('html', () => { comments: false } }, - jsSelector: 'script[type!="text/x-handlebars-template"]', css: { keepSpecialComments: 1 },