我需要为特定文件应用构建任务.为了找到它们,我使用典型的模板.但我无法理解如何从gulp.src传递参数(文件路径).
理想的解决方案.
gulp.task('bundles', function() {
gulp.src('bundles/**/*.js').
pipe(gulp.start('build', file.path));
});
gulp.task('build', function (path) {
// use here
});
Run Code Online (Sandbox Code Playgroud)
问题有点陈旧,我不确定我完全理解你想要在这里实现的目标,但我认为你正在寻找的是懒惰管道
如果这不是您想要的,您可能需要澄清您的问题
用法示例:
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/');
});
Run Code Online (Sandbox Code Playgroud)
基本上,lazypipe您可以创建一个管道以供将来使用;希望这有帮助
| 归档时间: |
|
| 查看次数: |
4004 次 |
| 最近记录: |