File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -588,6 +588,27 @@ class Encore {
588
588
return this ;
589
589
}
590
590
591
+ /**
592
+ * Configure the devServer.watchOptions configuration, only when the dev server is running.
593
+ *
594
+ * https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
595
+ * https://webpack.js.org/configuration/watch/
596
+ *
597
+ * Encore.configureDevServerWatchOptions(function(watchOptions) {
598
+ * // change the configuration
599
+ *
600
+ * watchOptions.poll = 250;
601
+ * });
602
+ *
603
+ * @param {function } callback
604
+ * @returns {Encore }
605
+ */
606
+ configureDevServerWatchOptions ( callback ) {
607
+ webpackConfig . configureDevServerWatchOptions ( callback ) ;
608
+
609
+ return this ;
610
+ }
611
+
591
612
/**
592
613
* Automatically make some variables available everywhere!
593
614
*
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ class WebpackConfig {
94
94
this . shouldUseSingleRuntimeChunk = null ;
95
95
this . shouldSplitEntryChunks = false ;
96
96
this . splitChunksConfigurationCallback = ( ) => { } ;
97
+ this . devServerWatchOptionsConfigurationCallback = ( ) => { } ;
97
98
this . vueLoaderOptionsCallback = ( ) => { } ;
98
99
this . eslintLoaderOptionsCallback = ( ) => { } ;
99
100
this . tsConfigurationCallback = ( ) => { } ;
@@ -395,6 +396,14 @@ class WebpackConfig {
395
396
this . splitChunksConfigurationCallback = callback ;
396
397
}
397
398
399
+ configureDevServerWatchOptions ( callback ) {
400
+ if ( typeof callback !== 'function' ) {
401
+ throw new Error ( 'Argument 1 to configureDevServerWatchOptions() must be a callback function.' ) ;
402
+ }
403
+
404
+ this . devServerWatchOptionsConfigurationCallback = callback ;
405
+ }
406
+
398
407
createSharedEntry ( name , file ) {
399
408
if ( this . shouldSplitEntryChunks ) {
400
409
throw new Error ( 'Using splitEntryChunks() and createSharedEntry() together is not supported. Use one of these strategies only to optimize your build.' ) ;
Original file line number Diff line number Diff line change @@ -527,6 +527,11 @@ class ConfigGenerator {
527
527
528
528
buildDevServerConfig ( ) {
529
529
const contentBase = pathUtil . getContentBase ( this . webpackConfig ) ;
530
+ const watchOptions = {
531
+ ignored : / n o d e _ m o d u l e s /
532
+ } ;
533
+
534
+ this . webpackConfig . devServerWatchOptionsConfigurationCallback ( watchOptions ) ;
530
535
531
536
return {
532
537
contentBase : contentBase ,
@@ -539,9 +544,7 @@ class ConfigGenerator {
539
544
quiet : true ,
540
545
compress : true ,
541
546
historyApiFallback : true ,
542
- watchOptions : {
543
- ignored : / n o d e _ m o d u l e s /
544
- } ,
547
+ watchOptions : watchOptions ,
545
548
https : this . webpackConfig . useDevServerInHttps ( )
546
549
} ;
547
550
}
You can’t perform that action at this time.
0 commit comments