Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Gulp task with params?

Tags:

gulp

I need to apply a build task for specific files. For finding them, I use the typical template. But I can't understood how to pass the arguments (file path) from gulp.src.

Desirable solution.

gulp.task('bundles', function() {
  gulp.src('bundles/**/*.js').
    pipe(gulp.start('build', file.path));
});

gulp.task('build', function (path) {
  // use here
});
like image 735
NiLL Avatar asked Nov 01 '22 23:11

NiLL


1 Answers

Question is a bit stale and I am not sure I totally understand what you're trying to achieve here, but I think what you're looking for is lazypipe

You might want to clarify your question if that's not what you're looking for

Example Usage:

var lazypipe = require('lazypipe'),
g = require('gulp-load-plugins')({lazy: true}),

jsTransformPipe = lazypipe()
    .pipe(g.jshint) // <-- Notice the notation: g.jshint, not g.jshint()
    .pipe(g.concat, 'bundle.js'), // <-- Notice how the param is passed to g.concat, as a second param to .pipe()

jsSourcePipe = lazypipe()
    .pipe(gulp.src, './**/*.js');

gulp.task('bundle', function() {
    jsSourcePipe()
        .pipe(jsTransformPipe()) // <-- You execute the lazypipe by calling it as a function
        .pipe(gulp.dest('../build/');
});

With lazypipe you basically create a pipe for future use; hope this help

like image 66
Olivier Clément Avatar answered Jan 04 '23 14:01

Olivier Clément