【发布时间】:2017-05-23 14:44:01
【问题描述】:
如何使用vinyl 对象创建流,以便在其上使用 gulp.js 插件?
乙烯基物体示例:
var file = getFoo(); // An in-memory file as a vinyl object.
return gulp.src(file) // What to do here? gulp.src only accepts globs.
.pipe(css(opts)) // (gulp-clean-css)
.pipe(gulp.dest('...'));
lofihelsinki 的评论 (return file.pipe(css())...) 解决了第一种情况。
乙烯基对象和流的示例:
var file = getFoo();
return merge(gulp.src('*.css'), file)
.pipe(concat('foobar.css'))
.pipe(css(opts))
.pipe(gulp.dest('...'));
以两个乙烯基物体为例:
var file1 = getFoo();
var file2 = getBar();
return merge(file1, file2) // (gulp-merge)
.pipe(concat('foobar.css')) // (gulp-concat)
.pipe(css(opts))
.pipe(gulp.dest('...'));
【问题讨论】:
-
return file.pipe(css())工作吗? -
它有效,谢谢!我还有一个没有帮助的案例,我会在几分钟内更新问题。
-
我会把它变成答案。
标签: javascript node.js build gulp