Gulp-tap: how to use it?

1.4k Views Asked by At

I have been trying to make one of my gulp task work, but can't figure out how to use the gulp-tap for my specific case.

I want to take the filename of the current processed amp-html file and use it to import the css file with the same name into the file.

Current incomplete task :

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));
});

One of my many tries (simplified) :

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));
});

How can I make it work with gulp-tap ? I actually don't understand how to pick-up the stream and tried in so many ways...

Thank you in advance for your help

0

There are 0 best solutions below