Skip to content

Question: How do I use this to parallelize execution? #9

Description

@Giszmo

So I use gulp-html-minifier-terser on 875 html files which takes 4 minutes on my 24 core machine and uses one core I think.
I would hope to use your tool to get that down to much less. 10s maybe?

I'm not experienced with gulp but the task looks like this:

const htmlmin = require("gulp-html-minifier-terser");
gulp.task("minify", () => {
  return gulp
    .src("_site/**/*.html")
    .pipe(
      htmlmin({
        collapseWhitespace: true,
        removeComments: true,
        minifyCSS: true,
        minifyJS: true,
      })
    )
    .pipe(gulp.dest("_site"));
});

and applying parallel-transform I get to instantiate htmlmin but not to actually apply it to the files. What is missing here:

const htmlmin = require('gulp-html-minifier-terser');
const transform = require('parallel-transform');

gulp.task("minify", () => {
  return gulp
    .src("_site/**/*.html")
    .pipe(
      transform(24, {ordered:false}, (file, callback) => {
        htmlmin({
          collapseWhitespace: true,
          removeComments: true,
          minifyCSS: true,
          minifyJS: true,
        })
        callback(null, file)
      })
    )
    .pipe(gulp.dest("_site"));
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions