1

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

brclz
  • 806
  • 9
  • 23
  • I just found out [here](http://www.academytimes.com/solved/7390076244/get-current-file-name-in-gulp-stream) that `gulp-foreach` might do what I want... I will look a bit further into it. – brclz Feb 18 '17 at 12:13

0 Answers0