How to configurate the Gulp plugins dynaminally (inside pipeline individually for each file)? #2688
-
I started this discussion after has not been answered in Stack Overflow even during bounty. But I still don't believe that what I want is impossible. Consider the the example of standard usage of gulp-postcss plugin: gulp.task('default', function () {
var plugins = [nested];
return gulp.src('in.sss')
.pipe(postcss(plugins, { parser: sugarss }))
.pipe(gulp.dest('out'));
}); Besides this statis cofiguration scenario, gulp-postcss allows to cofigurate itself dynamically: pipe(gulpPostCSS((file: Vinyl): { plugins: Array<unknown>; } => ({
plugins: [
Autoprefixer,
CSS_Nano({
preset: [
"default",
{
// Vinyl allows to add custom properties like "someBooleanFlag"
discardComments: file.someBooleanFlag
}
]
})
]
}))). But the gulp-pug plugin, for example, does not provide the callback allows to make the dynamic configuration dependent on Vinyl file: declare function GulpPug(options?: GulpPug.Options): Transform; How to config this plugin an other plugins which does not provide the callback depending on specific Vinyl file? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
It is generally expected that you will use gulp-if to match vinyl files and provide different plugin streams. That "function" config object in gulp-postcss is really a recommended pattern. |
Beta Was this translation helpful? Give feedback.
It is generally expected that you will use gulp-if to match vinyl files and provide different plugin streams. That "function" config object in gulp-postcss is really a recommended pattern.