gulp-useref
gulp-useref copied to clipboard
Can't run call gulp-useref from parallel gulp workflows
I tried to run useref from two task in parallel, using the new gulp 4 gulp.parallel method. The result is that one of the tasks almost always gets an error (no stack), or that I get the error Error: stream.push() after EOF.
After looking at index.js, I have a suspicion at to what the problem is:
streamManager = require('./lib/streamManager');
module.exports = function (options) {
streamManager.transforms = Array.prototype.slice.call(arguments, 1);
streamManager.options = options || {};
streamManager.additionalStreams();
return through.obj(streamManager.transformFunction, streamManager.flushFunction);
};
Instead of setting properties on a global streamManager object, you could just pass these in as arguments to a function? If you approve, I'll try to find the time to submit a pull request this week.
I think I'm facing the same issue, although I'm still using gulp 3.
To support localisation (in a SEO friendly way) I process the resources in parallel streams, one for each supported locale (called version in code). My minification task looks like this:
gulp.task('minify', function () {
return execForLocales(function (version) {
return gulp.src(version.tmp + '/*.html')
.pipe(useref())
.pipe(defer())
.pipe(gulpif('*.html', htmlmin({
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: false,
minifyCSS: true,
minifyJS: true
})))
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', cssnano()))
.pipe(gulp.dest(version.dist));
});
});
function execForLocales(task) {
var tasks = versions.map(function (version) {
return task(version);
});
return merge(tasks);
}
This all works if I process it for one locale only but fails without any error if I try to process more locales.
Yup seems similar alright, me using gulp4 probably has nothing to do with it.
On Mon, Apr 11, 2016 at 12:38 PM Jonas Zuberbuehler < [email protected]> wrote:
I think I'm facing the same issue, although I'm still using gulp 3.
To support localisation (in a SEO friendly way) I process the resources in parallel streams, one for each supported locale (called version in code). My minification task looks like this:
gulp.task('minify', function () { return execForLocales(function (version) { return gulp.src(version.tmp + '/.html') .pipe(useref()) .pipe(defer()) .pipe(gulpif('.html', htmlmin({ collapseWhitespace: true, conservativeCollapse: true, removeComments: false, minifyCSS: true, minifyJS: true }))) .pipe(gulpif('.js', uglify())) .pipe(gulpif('.css', cssnano())) .pipe(gulp.dest(version.dist)); }); }); function execForLocales(task) { var tasks = versions.map(function (version) { return task(version); }); return merge(tasks); }
This all works if I process it for one locale only but fails without any error if I try to process more locales.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jonkemp/gulp-useref/issues/201#issuecomment-208254797
+1 - this is also a problem for our parallel build pipeline
Still hoping for @jonkemp to weigh in on this.. In the mean time I've switched to gulp-usemin, as that seems to work with parallel workflows.
Have you tried it with the latest version 3.1.0?
Yep, still have the same problems. I'll try to create a minimal reproduction, but really you just need to run any sort of build in parallel.
I am working on a refactor which would get rid of streamManager.js. I plan on merging it in sometime this weekend. That may do what you are wanting.
Yeah, looks like reverting to 3.0.4 has resolved this issue for now, until @jonkemp merges in his changes to remove streamManager
Version 3.1.2 is out. Please try with the latest version and see if that fixes the issue.
Just hit the same issue running 3.1.2
Same issue running 3.1.2 except it's june of 2017 now......
@NullSoldier let me know if you're willing to help!