Completed
Pull Request — develop (#111)
by Xaver
01:06
created

gulp/tasks/htmlMin.js   A

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 28
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 3
c 1
b 0
f 0
nc 1
mnd 0
bc 3
fnc 3
dl 0
loc 28
rs 10
bpm 1
cpm 1
noi 0
1
module.exports = function (gulp, plugins, config) {
2
  const fs = require('fs');
3
  return function htmlmin() {
4
    return gulp.src(config.build + '/*.html')
5
      .pipe(plugins.inject(gulp.src(['config.json']), {
6
        starttag: '<!-- inject:config -->',
7
        transform: function (filePath, file) {
8
          return '<script>var jsonData =' +
9
            file.contents.toString('utf8')
10
              .replace('<!-- inject:cache-breaker -->',
11
                Math.random().toString(12).substring(7)) +
12
            ';</script>'
13
            ;
14
        }
15
      }))
16
      .pipe(plugins.realFavicon.injectFaviconMarkups(JSON.parse(fs.readFileSync(config.faviconData)).favicon.html_code))
17
      .pipe(plugins.kyhInlineSource({ compress: false }))
18
      .pipe(plugins.cacheBust({
19
        type: 'timestamp'
20
      }))
21
      .pipe(plugins.htmlmin({
22
        removeComments: true,
23
        collapseWhitespace: true,
24
        minifyJS: true
25
      }))
26
      .pipe(gulp.dest(config.build));
27
  };
28
};
29