File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -652,6 +652,27 @@ class Encore {
652
652
return this ;
653
653
}
654
654
655
+ /**
656
+ * Configure the devServer configuration.
657
+ *
658
+ * https://webpack.js.org/configuration/dev-server
659
+ *
660
+ * ```
661
+ * Encore.configureDevServerOptions(function(options) {
662
+ * // change the configuration
663
+ * options
664
+ * });
665
+ * ```
666
+ *
667
+ * @param {function } callback
668
+ * @returns {Encore }
669
+ */
670
+ configureDevServerOptions ( callback ) {
671
+ webpackConfig . configureDevServerOptions ( callback ) ;
672
+
673
+ return this ;
674
+ }
675
+
655
676
/**
656
677
* Automatically make some variables available everywhere!
657
678
*
Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ class WebpackConfig {
144
144
this . cssLoaderConfigurationCallback = ( ) => { } ;
145
145
this . splitChunksConfigurationCallback = ( ) => { } ;
146
146
this . watchOptionsConfigurationCallback = ( ) => { } ;
147
+ this . devServerOptionsConfigurationCallback = ( ) => { } ;
147
148
this . vueLoaderOptionsCallback = ( ) => { } ;
148
149
this . eslintLoaderOptionsCallback = ( ) => { } ;
149
150
this . tsConfigurationCallback = ( ) => { } ;
@@ -499,6 +500,14 @@ class WebpackConfig {
499
500
this . watchOptionsConfigurationCallback = callback ;
500
501
}
501
502
503
+ configureDevServerOptions ( callback ) {
504
+ if ( typeof callback !== 'function' ) {
505
+ throw new Error ( 'Argument 1 to configureDevServerOptions() must be a callback function.' ) ;
506
+ }
507
+
508
+ this . devServerOptionsConfigurationCallback = callback ;
509
+ }
510
+
502
511
createSharedEntry ( name , file ) {
503
512
if ( this . shouldSplitEntryChunks ) {
504
513
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 @@ -613,7 +613,7 @@ class ConfigGenerator {
613
613
buildDevServerConfig ( ) {
614
614
const contentBase = pathUtil . getContentBase ( this . webpackConfig ) ;
615
615
616
- return {
616
+ const devServerOptions = {
617
617
contentBase : contentBase ,
618
618
// this doesn't appear to be necessary, but here in case
619
619
publicPath : this . webpackConfig . getRealPublicPath ( ) ,
@@ -627,6 +627,11 @@ class ConfigGenerator {
627
627
watchOptions : this . buildWatchOptionsConfig ( ) ,
628
628
https : this . webpackConfig . useDevServerInHttps ( )
629
629
} ;
630
+
631
+ return applyOptionsCallback (
632
+ this . webpackConfig . devServerOptionsConfigurationCallback ,
633
+ devServerOptions
634
+ ) ;
630
635
}
631
636
}
632
637
You can’t perform that action at this time.
0 commit comments