File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,9 @@ class WebpackConfig {
100100 this . eslintLoaderOptionsCallback = ( ) => { } ;
101101 this . tsConfigurationCallback = ( ) => { } ;
102102 this . handlebarsConfigurationCallback = ( ) => { } ;
103+ this . loaderConfigurationCallbacks = {
104+ 'eslint' : ( ) => { } ,
105+ } ;
103106
104107 // Plugins options
105108 this . cleanWebpackPluginPaths = [ '**/*' ] ;
@@ -716,6 +719,18 @@ class WebpackConfig {
716719 } ) ;
717720 }
718721
722+ configureLoaderRule ( name , callback ) {
723+ if ( ! ( name in this . loaderConfigurationCallbacks ) ) {
724+ throw new Error ( `Loader "${ name } " is not configurable. Either open an issue or a pull request.` ) ;
725+ }
726+
727+ if ( typeof callback !== 'function' ) {
728+ throw new Error ( 'Argument 2 to configureLoaderRule() must be a callback function.' ) ;
729+ }
730+
731+ this . loaderConfigurationCallbacks [ name ] = callback ;
732+ }
733+
719734 useDevServer ( ) {
720735 return this . runtimeConfig . useDevServer ;
721736 }
Original file line number Diff line number Diff line change @@ -357,13 +357,13 @@ class ConfigGenerator {
357357 }
358358
359359 if ( this . webpackConfig . useEslintLoader ) {
360- rules . push ( {
360+ rules . push ( applyOptionsCallback ( this . webpackConfig . loaderConfigurationCallbacks [ 'eslint' ] , {
361361 test : / \. j s x ? $ / ,
362362 loader : 'eslint-loader' ,
363363 exclude : / n o d e _ m o d u l e s / ,
364364 enforce : 'pre' ,
365365 options : eslintLoaderUtil . getOptions ( this . webpackConfig )
366- } ) ;
366+ } ) ) ;
367367 }
368368
369369 if ( this . webpackConfig . useTypeScriptLoader ) {
You can’t perform that action at this time.
0 commit comments