如何在gulp中配置嵌套插件的选项? 我有一个gulp任务,使用gulp-inline来内联任何css和js。
gulp-inline具有设置css处理器的选项
gulp.task('html', function () {
gulp.src(source + '**/*.+(html|php)')
.pipe($.plumber())
.pipe($.inline({
base: source,
js: $.uglify,
css: $.cleanCss,
disabledTypes: ['svg', 'img']
}))
.pipe(gulp.dest(build))
});
理想情况下,在运行任务时,我想为css和js
声明配置选项gulp.task('html', function () {
gulp.src(source + '**/*.+(html|php)')
.pipe($.plumber())
.pipe($.inline({
base: source,
js: $.uglify,
css: $.cleanCss({
keepBreaks: false,
advanced: false,
keepSpecialComments: '*',
aggressiveMerging: false
}),
disabledTypes: ['svg', 'img']
}))
.pipe(gulp.dest(build))
});
答案 0 :(得分:1)
只需传递一个返回cleanCss
变换的函数:
gulp.task('html', function () {
gulp.src(source + '**/*.+(html|php)')
.pipe($.plumber())
.pipe($.inline({
base: source,
js: $.uglify,
css: function() {
return $.cleanCss({ /* options */ });
},
disabledTypes: ['svg', 'img']
}))
.pipe(gulp.dest(build))
});