1

我一直在尝试使我的 gulp 任务之一工作,但无法弄清楚如何在我的特定情况下使用 gulp-tap。

我想取当前处理的 amp-html 文件的文件名,并用它来将同名的 css 文件导入到文件中。

当前未完成的任务:

gulp.task('build:html', function () {
    return gulp.src(SOURCE_PATH+AMP_FILES)
        .pipe(htmlreplace({
            'cssInline': {
                'src': gulp.src(TMP_PATH + *CURRENT-AMP-FILENAME* + '.css'),
                'tpl': '<style amp-custom>%s</style>'
            }
        }))
        .pipe(gulp.dest(BUILD_PATH));
});

我的许多尝试之一(简化):

gulp.task('build:html', function () {
    return gulp.src(SOURCE_PATH+AMP_FILES)
        .pipe(tap(function(file, t) {
            var filename = path.basename(file.path);

            return t
                .pipe(htmlreplace({
                'cssInline': {
                    'src': gulp.src(TMP_PATH+filename + '.css'),
                    'tpl': '<style amp-custom>%s</style>'
                }
            }));
        }))
        .pipe(gulp.dest(BUILD_PATH));
});

我怎样才能使它与 gulp-tap 一起工作?我实际上不明白如何接流并尝试了很多方法......

预先感谢您的帮助

4

0 回答 0