From 3791729f92021993f35ba7a9245cfa352b8b71b8 Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Tue, 17 Mar 2020 14:34:12 +0100
Subject: [PATCH] [enh] Fix release

---
 gulpfile.js                            |  5 +++--
 hooks/after_prepare/020_remove_code.js |  2 +-
 hooks/after_prepare/040_useref.js      | 11 ++++-------
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index 8670049aa..0684b66fb 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -277,6 +277,7 @@ function webClean() {
 
 function webCopyFiles() {
   log(colors.green('Preparing dist/web files...'));
+  let htmlminOptions = {removeComments: true, collapseWhitespace: true};
 
   var tmpPath = './dist/web/www';
   return es.merge(
@@ -291,7 +292,7 @@ function webCopyFiles() {
       .pipe(removeCode({"no-device": true}))
       .pipe(removeHtml('.hidden-no-device'))
       .pipe(removeHtml('[remove-if][remove-if="no-device"]'))
-      .pipe(htmlmin())
+      .pipe(htmlmin(htmlminOptions))
       .pipe(gulp.dest(tmpPath + '/templates')),
 
     // Copy index.html (and remove unused code)
@@ -299,7 +300,7 @@ function webCopyFiles() {
       .pipe(removeCode({'no-device': true}))
       .pipe(removeHtml('.hidden-no-device'))
       .pipe(removeHtml('[remove-if][remove-if="no-device"]'))
-      .pipe(htmlmin())
+      .pipe(htmlmin(/*no options, to keep comments*/))
       .pipe(gulp.dest(tmpPath)),
 
     // Copy API index.html
diff --git a/hooks/after_prepare/020_remove_code.js b/hooks/after_prepare/020_remove_code.js
index c6f738990..bfc0b0bff 100755
--- a/hooks/after_prepare/020_remove_code.js
+++ b/hooks/after_prepare/020_remove_code.js
@@ -67,7 +67,7 @@ if (rootdir) {
           .pipe(removeHtml('.hidden-xs.hidden-sm'))
           .pipe(removeHtml('.hidden-device'))
           .pipe(removeHtml('[remove-if][remove-if="device"]'))
-          .pipe(htmlmin(/*no options, to build comments*/))
+          .pipe(htmlmin(/*no options, to keep comments*/))
           .pipe(gulp.dest(wwwPath)),
 
         // Remove unused JS code + add ng annotations
diff --git a/hooks/after_prepare/040_useref.js b/hooks/after_prepare/040_useref.js
index 9325b2801..dcd693b6e 100755
--- a/hooks/after_prepare/040_useref.js
+++ b/hooks/after_prepare/040_useref.js
@@ -7,8 +7,6 @@ const gulp = require('gulp'),
   filter = require('gulp-filter'),
   uglify = require('gulp-uglify-es').default,
   csso = require('gulp-csso'),
-  rev = require('gulp-rev'),
-  revReplace = require('gulp-rev-replace'),
   log = require('fancy-log'),
   colors = require('ansi-colors');
 
@@ -42,9 +40,9 @@ if (rootdir && !skip) {
 
     let indexPath = path.join(wwwPath, 'index.html');
 
+    const indexFilter = filter('**/index.html', {restore: true});
     const jsFilter = filter(['**/*.js', '!**/vendor/*', '!**/config.js'], { restore: true });
     const cssFilter = filter('**/*.css', { restore: true });
-    const revFilesFilter = filter(['**/*', '!**/index.html', '!**/config.js'], { restore: true });
     const uglifyOptions = {
       toplevel: true,
       warnings: true,
@@ -69,16 +67,15 @@ if (rootdir && !skip) {
     es.concat(
       gulp.src(indexPath)
         .pipe(useref())      // Concatenate with gulp-useref
+
         .pipe(jsFilter)
         .pipe(uglify(uglifyOptions)) // Minify any javascript sources
         .pipe(jsFilter.restore)
+
         .pipe(cssFilter)
         .pipe(csso())               // Minify any CSS sources
         .pipe(cssFilter.restore)
-        .pipe(revFilesFilter)
-        .pipe(rev())                // Rename the concatenated files (but not index.html)
-        .pipe(revFilesFilter.restore)
-        .pipe(revReplace())         // Substitute in new filenames
+
         .pipe(gulp.dest(wwwPath))
      );
   }
-- 
GitLab