简体   繁体   中英

Gulp Jade and HTML templates

I have an AngularJS project that I have existing HTML templates and I want to also start using Jade templates. I want to create a single gulp task for the templates, but I am not sure how I can skip the Jade step for HTML files. Here is what I have:

gulp.task('templates', function () {
    return gulp.src('./client/views/**/*.{html, jade}')
        .pipe(jade())
        .pipe(htmlmin({
            collapseWhitespace: true,
            removeComments: true
        }))
        .pipe(templateCache({
            root: 'views/',
            module: 'omApp'
        })) 
        .pipe(gulp.dest('./client/dist/scripts/templates'));
});

Use gulp-if :

gulp.task('templates', function () {
return gulp.src('./client/views/**/*.{html, jade}')
    .pipe(gulpif(function(file) { 
        return /jade$/.test(file.path); 
    }, jade()))
    ....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM