@@ -4,25 +4,35 @@ const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
44module . exports = function override ( config , env ) {
55 config . resolve . alias [ "react-datepicker" ] = path . resolve ( __dirname , ".." ) ;
66 config . resolve . alias [ "react" ] = path . resolve ( __dirname , "node_modules/react" ) ;
7- //do stuff with the webpack config...
7+
8+ // Add raw-loader for specific example files
89 config . module . rules . push ( {
910 test : / \. j s / ,
1011 include : path . resolve ( __dirname , "src/examples" ) ,
1112 use : "raw-loader" ,
1213 } ) ;
14+
15+ // Remove ModuleScopePlugin to allow imports outside of 'src'
1316 config . resolve . plugins = config . resolve . plugins . filter (
1417 ( plugin ) => ! ( plugin instanceof ModuleScopePlugin ) ,
1518 ) ;
16- // Enable it, so that our custom .eslintrc for the examples will work
17- for ( let i = 0 ; i < config . module . rules . length ; i ++ ) {
18- if ( Array . isArray ( config . module . rules [ i ] . use ) ) {
19- for ( let j = 0 ; j < config . module . rules [ i ] . use . length ; j ++ ) {
20- if ( config . module . rules [ i ] . use [ j ] . loader . includes ( "eslint-loader" ) ) {
21- config . module . rules [ i ] . use [ j ] . options . useEslintrc = true ;
22- break ;
23- }
19+
20+ // Remove ESLint plugin if it exists
21+ config . plugins = config . plugins . filter (
22+ ( plugin ) => plugin . constructor . name !== "ESLintWebpackPlugin" ,
23+ ) ;
24+
25+ // Skip ESLint loader by removing the eslint-loader rules
26+ config . module . rules = config . module . rules . filter ( ( rule ) => {
27+ if ( rule . use ) {
28+ if ( Array . isArray ( rule . use ) ) {
29+ return ! rule . use . some (
30+ ( { loader } ) => loader && loader . includes ( "eslint-loader" ) ,
31+ ) ;
2432 }
2533 }
26- }
34+ return true ;
35+ } ) ;
36+
2737 return config ;
2838} ;
0 commit comments