【问题标题】:Gulp. Gulp-If. How to call several plug-ins?吞咽。 Gulp-如果。如何调用几个插件?
【发布时间】:2016-03-29 17:23:01
【问题描述】:

请告诉我如何实现调用css的几个插件。

gulp.task("useref", function() {
    return gulp.src("src/*.html")
        .pipe(useref())
        .pipe(gulpIf("*.js", uglify()))
        .pipe(gulpIf("*.css", combineMq(), cssnano())) // This does not work
        .pipe(gulp.dest("build"));
});

错误:

$ gulp useref
[20:21:12] Using gulpfile ~\Desktop\Gulp\gulpfile.js
[20:21:12] Starting 'useref'...

events.js:154
      throw er; // Unhandled 'error' event
      ^
 Error: D:\Users\Dmitry\Desktop\Gulp\index.html:1:1: Unknown word
<!DOCTYPE html>
^
<html lang="en">

【问题讨论】:

    标签: javascript node.js gulp gulp-useref


    【解决方案1】:

    你可以使用lazypipe

    var lazypipe = require('lazypipe');
    
    gulp.task("useref", function() {
      var cssPipeline = lazypipe()
        .pipe(cssnano)
        .pipe(combineMq, {
          beautify: false
        });
    
      return gulp.src("src/*.html")
        .pipe(useref())
        .pipe(gulpIf("*.js", uglify()))
        .pipe(gulpIf("*.css", cssPipeline()))
        .pipe(gulp.dest("build"));
    });
    

    【讨论】:

    • 我无法得到:(
    • 不要发布其他问题作为答案。编辑您的问题或在评论中提问。至于你的问题,看我的编辑。
    猜你喜欢
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    • 2014-07-03
    • 1970-01-01
    • 1970-01-01
    • 2014-08-18
    相关资源
    最近更新 更多