Gulp不创建文件夹? [英] Gulp doesn't create folder?
问题描述
当我缩小CSS时,我得到了来自各个库的字体的错误路径.因此,我创建了一个任务,将字体从我的 bower_components/
文件夹移动到 dist/public/fonts
:
When I minified my css, I was left with an incorrect path to the fonts from various libraries. So, I created a task to move the fonts from my bower_components/
folder to dist/public/fonts
:
gulp.task('doit', function() {
gulp.src(["public/bower_components/bootstrap/dist/fonts/*", "public/bower_components/font-awesome/fonts/*"])
.pipe(gulp.dest("dist/public/fonts"));
});
基本上,应该将我需要的所有字体都放到通用字体文件夹中,缩小的CSS现在应该可以访问该文件夹.
Basically that should throw any fonts I need into a generic fonts folder, which my minified css should now be able to access.
但是我运行它后, dist/public/fonts
不存在.为什么不呢?
But after I run it, dist/public/fonts
doesn't exist. Why not?
推荐答案
我不完全了解您 src
-ing的路径( public/bower_components
?),但我相信您会希望使用 gulp.src
的基本选项.
I don't fully understand the paths you're src
-ing (public/bower_components
?), but I believe you'll want to use the base
option for gulp.src
.
由于这两个glob具有不同的基础,因此建议将其分解为两个单独的任务,并构建第三个以将它们聚合为一个任务.否则,您需要进入合并流或 addSrc
插件.
Because these two globs will have different bases, I'd suggest breaking it into two separate tasks, and building a third to aggregate them into a single. Otherwise you'll need to get into merging streams or the addSrc
plugin.
gulp.task('copy:fonts:bootstrap', function () {
return gulp.src(
[
'public/bower_components/bootstrap/dist/fonts/**/*'
],
{
base: 'public/bower_components/bootstrap/dist/fonts'
}
)
.pipe(gulp.dest('dist/public/fonts'));
});
gulp.task('copy:fonts:fontawesome', function () {
return gulp.src(
[
'public/bower_components/font-awesome/fonts/**/*'
],
{
base: 'public/bower_components/font-awesome/fonts'
}
)
.pipe(gulp.dest('dist/public/fonts'));
});
gulp.task('copy:fonts', ['copy:fonts:bootstrap', 'copy:fonts:fontawesome']);
这篇关于Gulp不创建文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!