問題描述
當我縮小我的 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
的 base 選項.
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 不創建文件夾?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!