@@ -4,25 +4,35 @@ const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
4
4
module . exports = function override ( config , env ) {
5
5
config . resolve . alias [ "react-datepicker" ] = path . resolve ( __dirname , ".." ) ;
6
6
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
8
9
config . module . rules . push ( {
9
10
test : / \. j s / ,
10
11
include : path . resolve ( __dirname , "src/examples" ) ,
11
12
use : "raw-loader" ,
12
13
} ) ;
14
+
15
+ // Remove ModuleScopePlugin to allow imports outside of 'src'
13
16
config . resolve . plugins = config . resolve . plugins . filter (
14
17
( plugin ) => ! ( plugin instanceof ModuleScopePlugin ) ,
15
18
) ;
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
+ ) ;
24
32
}
25
33
}
26
- }
34
+ return true ;
35
+ } ) ;
36
+
27
37
return config ;
28
38
} ;
0 commit comments