-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Document gulp.start() #505
Comments
Also I wonder if I can pass on a callback to |
No you can't. I won't document gulp.start because we're removing it in the next version, see #355 |
Okay, will wait for the next version. Thx. But for now, is there a trick how I can call a gulp task inside a another running gulp task? Or pipe to there? |
Break tasks out into functions, then reuse them in other tasks if you need to |
@contra Yeah I had that in mind too but do not how to call a reusable function when I am already piping something. Can you show an example? |
@binarykitchen Have you looked at the gulp.task('js', function() {
return gulp.src('js/**/*.js')
.pipe(uglify())
.pipe(size())
.pipe(gulp.dest('dist'))
.pipe(lr());
});
gulp.task('css', function() {
return gulp.src('css/**/*.css')
.pipe(csso())
.pipe(size())
.pipe(gulp.dest('dist'))
.pipe(lr());
}); Into this: var end = lazypipe()
.pipe(size)
.pipe(gulp.dest, 'dist')
.pipe(lr);
gulp.task('js', function() {
return gulp.src('js/**/*.js')
.pipe(uglify())
.pipe(end());
});
gulp.task('css', function() {
return gulp.src('css/**/*.css')
.pipe(csso())
.pipe(end());
}); Does that solve the problem? |
Hmmm, that's almost what I want but few things are missing. Let me explain what I need here with a real example: function bundle(watch, cb) {
var bundler;
if (watch) {
bundler = watchify(paths.browserEntry);
} else {
bundler = watchify.browserify(paths.browserEntry);
}
var rebundle = function(cb) {
bundler
.bundle({
insertGlobals: false,
debug: !settings.PRODUCTION // for source maps
})
.on('error', util.log)
.on('log', util.log)
.on('end', cb)
// how can I call clean:js here???
// this is the point where I want to clean
// the javascript directory before
// browserify is going to write the new file
.pipe(source(paths.browserEntry))
.pipe(buffer()) // because the next steps do not support streams
.pipe(uglify())
.pipe(concat('bundle.min.js'))
.pipe(rev())
.pipe(gulp.dest(paths.compressedBrowser))
.pipe(rev.manifest())
.pipe(gulp.dest(path.join(paths.rev, 'js')));
};
// when not watching, just bundle once
if (!watch) {
rebundle(cb);
} else {
bundler.on('update', rebundle);
cb();
}
}
gulp.task('clean:js', function() {
return gulp.src(paths.compressedBrowser, {read: false}).pipe(clean());
});
gulp.task('browserify', ['clean:js'], function(cb) {
bundle(false, cb);
});
gulp.task('watchify', ['clean:js'], function(cb) {
bundle(true, cb);
}); See my comment inbetween. How can I move clean:js between these lines. Lazypipe won't help here because you cannot have two different sources within lazypipes. |
Okay so you're making a task that never ends in some cases - use the rimraf module to delete folders |
@contra Yeah, it never ends due to the |
@binarykitchen That's not the gulp way. I highly recommend against using gulp-clean/gulp-rimraf unless you are deleting files that match a specific glob. If you need to just wipe a folder using rimraf is much cleaner and faster |
Okay, I get it now. Thanks for your advice! |
gulp.task('build', ['clean', 'task1']); dont work because of parallelism.. Dirty solution: gulp.task('build', ['clean'], function() {
gulp.start('task1');
}); What is the best practice to solve this without having task1 to depend on the clean task? |
gulp.start() still works, is it deprecated? is there a better way to do the following if one is not using gulpfile.js?
|
I have the same question as @wfayeBerman . I'll explain my use case because it's an edge case (I'm good at those I guess...). I want to use gulp from within another node process. The other node process is an express app. An example use case is when someone in the UI hits the "publish" button a POST request to the server is made. Within the request handler I want to run the gulp "publish" task which takes some data from the disk and a database and uploads it to S3. Since gulp does a great job with this task, I don't see a reason not to use gulp or to reinvent the wheel. But I understand that using gulp on something else than a development machine is not the intended use-case, but a viable one. |
No documentation because it's being removed from the code? Looks like it's stil there after 2 years? |
@basvandenheuvel all work is being done in the 4.0 branch. This is not a supported API and will not be documented. Locking. |
I've been searching for docu on how
gulp.start()
works.I wonder if I can pass on parameters to a new gulp task through that start function?
Also, how can I start another gulp task inside a running gulp task? I mean, can I pipe gulp.start to somewhere else in the middle?
The text was updated successfully, but these errors were encountered: