我在使用 glob 和 gulp.dest() 时遇到问题。我的任务看起来像这样
return gulp.src('./clients/*/assets/less/*.less',{ base: process.cwd() })
.pipe(less({
paths:[path.join(__dirname, 'less')]
}).on('error', function(err){
gutil.log(err);
this.emit('end');
}))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest(function(file){
return path.normalize(path.join(file.path, '../css'));
}));
例如,如果我的路径是./clients/my-client/assets/less/style.less
路径最终是 `./clients/my-client/assets/css/my-client/assets/less/css 我尝试使用重命名函数,例如
.pipe(rename(function (path) {
path.dirname = '';
}))
之前但所做的只是将文件放在./clients/css/style.css
所需的目录应该是./clients/my-client/assets/less/style.css
并且认为这一切都相当容易,也许它是,但我真的很挣扎。任何帮助将非常感激!