排除某些目录 gulp-inject
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
文件夹,所有 client-side 代码都位于该文件夹中。我不想在我生成的 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
文件夹 AFTER 我告诉它排除 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});
在包含 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
文件夹,所有 client-side 代码都位于该文件夹中。我不想在我生成的 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
文件夹 AFTER 我告诉它排除 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});