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

Can't run call gulp-useref from parallel gulp workflows #201

Open
orzarchi opened this issue Apr 10, 2016 · 12 comments
Open

Can't run call gulp-useref from parallel gulp workflows #201

orzarchi opened this issue Apr 10, 2016 · 12 comments

Comments

@orzarchi
Copy link

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.

@jonaszuberbuehler
Copy link

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.

@orzarchi
Copy link
Author

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 <
notifications@github.com> 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
#201 (comment)

@bryk
Copy link

bryk commented Apr 28, 2016

+1 - this is also a problem for our parallel build pipeline

@orzarchi
Copy link
Author

orzarchi commented May 6, 2016

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.

@jonkemp
Copy link
Owner

jonkemp commented May 6, 2016

Have you tried it with the latest version 3.1.0?

@orzarchi
Copy link
Author

orzarchi commented May 6, 2016

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.

@jonkemp
Copy link
Owner

jonkemp commented May 6, 2016

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.

alxbenz pushed a commit to virtualidentityag/gulp-frontend-boilerplate that referenced this issue May 17, 2016
@noderat
Copy link

noderat commented Jun 16, 2016

Yeah, looks like reverting to 3.0.4 has resolved this issue for now, until @jonkemp merges in his changes to remove streamManager

@jonkemp
Copy link
Owner

jonkemp commented Aug 31, 2016

Version 3.1.2 is out. Please try with the latest version and see if that fixes the issue.

@danjarvis
Copy link

Just hit the same issue running 3.1.2

@NullSoldier
Copy link

Same issue running 3.1.2 except it's june of 2017 now......

@jonkemp
Copy link
Owner

jonkemp commented Jun 5, 2017

@NullSoldier let me know if you're willing to help!

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

7 participants