Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Giszmo opened this issue Jan 2, 2021 · 0 comments
Open

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

Giszmo opened this issue Jan 2, 2021 · 0 comments

Comments

@Giszmo
Copy link

Giszmo commented Jan 2, 2021

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"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant