search

Home  >  Q&A  >  body text

gulp traverses folders to compress css, invalid

gulp.task('cssoModule', ['copyModule'], function() {
    return gulp.src('./dist/module/*/*.css',function(err,files) {
        console.log("cssoModule ERROR: "+err);
        files.map(function (entry) {
            var destUrl = entry.substring(0,entry.lastIndexOf('/'));
            console.log(destUrl);
            csso()
            .pipe(gulp.dest(destUrl));
        })
    })
});

This is invalid. I don’t know if gulp has written it wrong. Both addresses destUrl can be obtained.

#
漂亮男人漂亮男人2705 days ago1073

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-06-30 10:00:08

    gulp.task('cssoModule', ['copyModule'], function() {
        return gulp.src('./dist/module/*/*.css',function(err,files) {
            console.log("cssoModule ERROR: "+err);
            files.map(function (entry) {
                var destUrl = entry.substring(0,entry.lastIndexOf('/'));
                console.log(destUrl);
                
                // 改成这样试试
                return gulp.src(entry)
                    .pipe(csso())
                    .pipe(gulp.dest(destUrl));
                
                
            })
        })
    });

    reply
    0
  • 阿神

    阿神2017-06-30 10:00:08

    It’s better to have enough food and clothing by yourself
    http://www.gulpjs.com.cn/docs...

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-06-30 10:00:08

    No Chinese characters appear in the directory

    reply
    0
  • Cancelreply