[英]excluding certain directories gulp-inject
在包含css
和javascript
文件時忽略bower_components
gulp.task('files', function(){
var target = gulp.src("./client/index.html");
var sources = gulp.src(["./client/**/*.js", "./client/**/*.css"], {read: false});
target.pipe(inject(sources))
.pipe(gulp.dest("./client"))
});
我不想在index.html中包含client/bower_components
? 有沒有辦法可以指定要包含在我的sources
文件?
像這樣排除bower_components
。
var sources = gulp.src(["!./client/bower_components/**/*"
"./client/**/*.js", "./client/**/*.css"], {read: false});
我相信這個命令很重要。 例如,假設我的client
文件夾中有一個tests
文件夾,其中所有客戶端代碼都存在。 我不想在我生成的index.html
包含我的規范。
原來我有
var sources = gulp.src([
'!./client/tests/**/*', // exclude the specs up front, didn't work
'./client/config/app.js',
'./client/config/*.js',
'./client/**/*.js', // conflicts with the tests exclusion
'./client/**/*.css'
], {read: false});
但它仍然將規格注入我的HTML! 問題是我告訴gulp在我告訴它排除其中一個client
文件夾之后包含所有client
client
文件夾。 所以我只需要將排除的文件夾放在最后以解決問題。
var sources = gulp.src([
'./client/config/app.js',
'./client/config/*.js',
'./client/**/*.js',
'./client/**/*.css',
'!./client/tests/**/*' // exclude the specs at the end, works!
], {read: false});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.