[英]Using node.js functions in gulp task
I'm looking to integrate more-css( https://github.com/army8735/more ) into my gulp workflow. 我希望将more-css( https://github.com/army8735/more )集成到我的gulp工作流程中。 I've tried several different options.
我尝试了几种不同的选择。 I'm not sure what the syntax to include a function of this type would be.
我不确定要包含这种类型的函数的语法是什么。 Could someone clarify?
有人可以澄清吗?
gulp.task('more-css', function () {
var moreCss = require('more-css');
return gulp.src('./in')
.pipe(moreCss.compress('paint.css', true))
.pipe(gulp.dest('./out'));
});
var moreCss=require('more-css');
gulp.task('build', function(){
var cssFile='paint.css';//path to paint.css
gulp.src(cssFile)
.pipe(moreCss.compress(gulp.src(cssFile), true))
.pipe(gulp.dest('./out'));
});
@Pradyumna's answer is not correct; @Pradyumna的答案不正确; gulp plugins are basically transform streams.
gulp插件基本上是转换流。 It's not enough to use the node API directly, you have to wrap it in some streaming logic.
直接使用节点API是不够的,您必须将其包装在某些流逻辑中。 Having had a brief look around on npm, there isn't a gulp plugin that you can use for
more-css
, so I made one. 在npm上进行了简单的浏览后,没有一个gulp插件可用于
more-css
,所以我做了一个。 Install with: 安装方式:
npm install gulp-more-css --save-dev
And a code example: 和一个代码示例:
var gulp = require('gulp');
var moreCSS = require('gulp-more-css');
gulp.task('default', function() {
return gulp.src('./in')
.pipe(moreCSS())
.pipe(gulp.dest('./out'));
});
https://github.com/ben-eb/gulp-more-css https://github.com/ben-eb/gulp-more-css
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.