Javascript将数组传递给`gulp.src`

时间:2018-09-11 14:10:03

标签: javascript gulp

在我的gulpfile.js中,如何正确地将数组传递给gulp.src并遍历其内容?这是我现有的代码,需要更正:

const paths = {
    themes: [
        {
            name: 'cat',
            js: ['src/cat/js/**', 'src/cat/assets/js/**']
        },
        {
            name: 'dog',
            js: ['src/dog/js/**', 'src/dog/assets/js/**']
        }
    ],
    dist: {
        js: 'dist/js'
    }
}

gulp.task( 'theme:assets',
    function(done){
        paths.themes.forEach(function(theme){
            gulp.src(`${theme.js}`)
            .pipe(newer(paths.dist.js + '/' + `${theme.name}`))
            .pipe(gulp.dest(paths.dist.js + '/' + `${theme.name}`));
        });
        done();
    }
);

0 个答案:

没有答案