我的任务是:
gulp.task('css-dependencies', function() {
return gulp.src(['bower_components/**/*.css','!bower_components/**/*.min.css'])
.pipe(rename({dirname: './css'}))
.pipe(gulp.dest('./'));
});它对所有其他组件都很好,但是我想使用animate.css,然后通过bower将它添加到一个名为animate.css的文件夹中。
Project
|
+-- bower_components
|
+-- animate.css
|
+--animate.css
+--animate.min.css (etc)这会导致gulp在重命名任务上失败:
错误: EISDIR:在一个目录上非法操作,在错误处打开‘~/css/airate.css’(本机)
除了特别豁免外,我又如何解决这个问题呢?
发布于 2016-11-25 11:59:17
您的问题是,gulp.src()中的模式匹配两件事:
bower_component/animate.cssbower_component/animate.css/animate.css然后继续执行一个rename({dirname: './css'}),这意味着您的结果是:
css/animate.csscss/animate.css两者显然不能同时存在。
您需要确保gulp.src()中的模式与任何目录本身不匹配(只有这些目录中的文件)。
gulp.src()在内部使用glob,gulp.src()的选项传递给glob。这意味着您可以使用 option of glob来防止目录匹配:
return gulp.src(['bower_components/**/*.css','!bower_components/**/*.min.css'], {nodir:true})
.pipe(rename({dirname: './css'}))
.pipe(gulp.dest('dist'));https://stackoverflow.com/questions/40797243
复制相似问题