Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
411 views
in Technique[技术] by (71.8m points)

gulp最新的gulp-uglify插件用了pump,这个怎么用,老是报错?

  • 想把src中的js文件做以下操作
    1.合并成一个all.js的文件
    2.压缩
    3.转移到dist/js目录下

    • 我的gulpfile.js这样写

    var uglify = require('gulp-uglify');  
        gulp.task('script', function() {
                .pipe(gulp.src('src/script/*.js'))
                .pipe(gulp.concat('all.js'))
                .pipe(uglify())
                .pipe(gulp.dest('dist/js'))         
    });

    结果是错的
    官网npm中uglify给出的提示是要用pump,如下:

        var uglify = require('gulp-uglify');
        var pump = require('pump');
     
       gulp.task('compress', function (cb) {
          pump([
                gulp.src('lib/*.js'),
                uglify(),
                gulp.dest('dist')
            ],
            cb
          );
        });

1、请问,用这个pump如何实现我上面说的功能?写了几遍都是错的

2、如果可以,可以讲一下pump和pipe的区别,我理解的一个是管道,一个是泵;用pump的原因好像是可以一次性捕捉到错误信息
git上关于pump的描述


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...