@@ -1147,11 +1147,16 @@ function watchAndSync(options, cb) {
1147
1147
var browserSync = require ( 'browser-sync' ) . create ( ) ;
1148
1148
browserSync . init ( { proxy : 'localhost:9000' } ) ;
1149
1149
1150
+ // When using the --focus=name flag, only **/name/**/*.* example files and
1151
+ // **/name.jade files are watched. This is useful for performance reasons.
1152
+ // Example: gulp serve-and-sync --focus=architecture
1153
+ var focus = argv . focus ;
1154
+
1150
1155
if ( options . devGuide ) {
1151
- devGuideExamplesWatch ( _devguideShredOptions , browserSync . reload ) ;
1156
+ devGuideExamplesWatch ( _devguideShredOptions , browserSync . reload , focus ) ;
1152
1157
}
1153
1158
if ( options . devGuideJade ) {
1154
- devGuideSharedJadeWatch ( { jadeDir : DOCS_PATH } , browserSync . reload ) ;
1159
+ devGuideSharedJadeWatch ( { jadeDir : DOCS_PATH } , browserSync . reload , focus ) ;
1155
1160
}
1156
1161
if ( options . apiDocs ) {
1157
1162
apiSourceWatch ( browserSync . reload ) ;
@@ -1218,8 +1223,9 @@ function apiExamplesWatch(postShredAction) {
1218
1223
} ) ;
1219
1224
}
1220
1225
1221
- function devGuideExamplesWatch ( shredOptions , postShredAction ) {
1222
- var includePattern = path . join ( shredOptions . examplesDir , '**/*.*' ) ;
1226
+ function devGuideExamplesWatch ( shredOptions , postShredAction , focus ) {
1227
+ var watchPattern = focus ? '**/' + focus + '/**/*.*' : '**/*.*' ;
1228
+ var includePattern = path . join ( shredOptions . examplesDir , watchPattern ) ;
1223
1229
// removed this version because gulp.watch has the same glob issue that dgeni has.
1224
1230
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
1225
1231
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
@@ -1235,8 +1241,9 @@ function devGuideExamplesWatch(shredOptions, postShredAction) {
1235
1241
} ) ;
1236
1242
}
1237
1243
1238
- function devGuideSharedJadeWatch ( shredOptions , postShredAction ) {
1239
- var includePattern = path . join ( DOCS_PATH , '**/*.jade' ) ;
1244
+ function devGuideSharedJadeWatch ( shredOptions , postShredAction , focus ) {
1245
+ var watchPattern = focus ? '**/' + focus + '.jade' : '**/*.jade' ;
1246
+ var includePattern = path . join ( DOCS_PATH , watchPattern ) ;
1240
1247
// removed this version because gulp.watch has the same glob issue that dgeni has.
1241
1248
// var excludePattern = '!' + path.join(shredOptions.jadeDir, '**/node_modules/**/*.*');
1242
1249
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
0 commit comments