@@ -26,7 +26,7 @@ class ConfigGroup extends GroupHelper {
2626 getConfigExtension ( configPath ) {
2727 for ( let i = this . extensions . length - 1 ; i >= 0 ; i -- ) {
2828 const tmpExt = this . extensions [ i ] ;
29- if ( configPath . indexOf ( tmpExt , configPath . length - tmpExt . length ) > - 1 ) {
29+ if ( configPath . includes ( tmpExt , configPath . length - tmpExt . length ) ) {
3030 return tmpExt ;
3131 }
3232 }
@@ -41,22 +41,30 @@ class ConfigGroup extends GroupHelper {
4141 } ;
4242 }
4343
44+ require ( path ) {
45+ const result = require ( path ) ;
46+ if ( result && result . __esModule && result . default ) {
47+ return result . default ;
48+ }
49+ return result ;
50+ }
51+
4452 requireConfig ( configPath ) {
4553 const { register } = this . args ;
4654
4755 this . configOptions = ( ( ) => {
4856 if ( register && register . length ) {
4957 module . paths . unshift ( resolve ( process . cwd ( ) , 'node_modules' ) ) ;
5058 register . forEach ( dep => {
51- const isRelative = [ "./" , " ../" , " .\\" , " ..\\" ] . some ( start => dep . startsWith ( start ) ) ;
59+ const isRelative = [ './' , ' ../' , ' .\\' , ' ..\\' ] . some ( start => dep . startsWith ( start ) ) ;
5260 if ( isRelative ) {
5361 require ( resolve ( process . cwd ( ) , dep ) ) ;
5462 } else {
5563 require ( dep ) ;
5664 }
5765 } ) ;
5866 }
59- return require ( configPath ) ;
67+ return this . require ( configPath ) ;
6068 } ) ( ) ;
6169 }
6270
@@ -81,7 +89,7 @@ class ConfigGroup extends GroupHelper {
8189 . map ( this . mapConfigArg . bind ( this ) ) ;
8290 if ( tmpConfigFiles . length ) {
8391 if ( ! config ) {
84- const defaultConfig = tmpConfigFiles . find ( p => ~ p . path . indexOf ( mode ) ) ;
92+ const defaultConfig = tmpConfigFiles . find ( p => p . path . includes ( mode ) ) ;
8593 this . configFiles = defaultConfig || tmpConfigFiles [ 0 ] ;
8694 }
8795 }
@@ -110,7 +118,7 @@ class ConfigGroup extends GroupHelper {
110118 const { merge } = this . args ;
111119 if ( merge ) {
112120 const newConfigPath = this . resolveFilePath ( merge , 'webpack.base' ) ;
113- const newConfig = newConfigPath ? require ( newConfigPath ) : null ;
121+ const newConfig = newConfigPath ? this . require ( newConfigPath ) : null ;
114122 this . opts [ 'options' ] = require ( 'webpack-merge' ) ( this . opts [ 'options' ] , newConfig ) ;
115123 }
116124 }
0 commit comments