Twitter bootstrap Gulp-将不同的文件保存到不同的路径无法按预期工作
任务: 预期产出为Twitter bootstrap Gulp-将不同的文件保存到不同的路径无法按预期工作,twitter-bootstrap,gulp,Twitter Bootstrap,Gulp,任务: 预期产出为 gulp.task('css', function() { return gulp.src([ 'node_modules/bootstrap/dist/css/bootstrap.min.css' ]) .pipe(gulp.dest('public/assets/css')) .pipe(gulp.src(['node_modules/bootstrap/dist/fonts/*']))
gulp.task('css', function() {
return gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.min.css'
])
.pipe(gulp.dest('public/assets/css'))
.pipe(gulp.src(['node_modules/bootstrap/dist/fonts/*']))
.pipe(gulp.dest('public/assets/fonts'))
});
相反,我得到的是
- assets/css
> bootstrap.min.css
- assets/fonts
> glyphicons-halflings-regular.eot
> glyphicons-halflings-regular.svg
> glyphicons-halflings-regular.ttf
> glyphicons-halflings-regular.woff
> glyphicons-halflings-regular.woff2
注意
- 引导css被复制到字体目录,但不应复制到字体目录
- 并非所有字体都被复制
我的任务怎么了?你不能添加这样的源代码。添加.pipe(gulp.src)时,您仍在处理上一个流,因此新的src将附加到上一个src。你要做的就是从当前的流中走出来
- assets/css
> bootstrap.min.css
- assets/fonts
> bootstrap.min.css
> glyphicons-halflings-regular.eot
> glyphicons-halflings-regular.svg
Gulpjs参考
测试脚本
gulp.task('css', function() {
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.min.css'
])
.pipe(gulp.dest('public/assets/css'))
return gulp.src(['node_modules/bootstrap/dist/fonts/*'])
.pipe(gulp.dest('public/assets/fonts'))
});
您的代码无法解决问题,因为您在设置字体dst之前返回。然而,您的链接确实存在,合并流是正确的解决方案。也许编辑你的答案?@brazorf你确定吗?这个版本基本上解决了这个问题。我已经附上了我的测试脚本和结果。我正在使用gulp-3.9.0
gulp.task('copy:csstest', function() {
gulp.src(['bower_components/bootstrap-sass/assets/stylesheets/_bootstrap.scss']).pipe(gulp.dest("build/scripts/folder1"));
return gulp.src(['bower_components/bootstrap-sass/assets/fonts/bootstrap/*']).pipe(gulp.dest("build/scripts/folder2"));
});