diff --git a/gulpfile.js b/gulpfile.js
index 8670049aa3649e48d8322f3e6e82acc01f3d220c..0684b66fb53bc6054be68b642058284c09ac2703 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 c6f738990a15f55c82a606acc7137e34e006ed21..bfc0b0bffab614dd74c9c8bd0a9224e99812f82f 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 9325b2801b31b8a385ac1dc7e5a2f8c6d54600de..dcd693b6edf30d820e204061ca44e2c1c3b74c1c 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))
      );
   }