@@ -27,24 +27,29 @@ module.exports = function(optimist, argv, convertOptions) {
2727 argv [ "optimize-occurence-order" ] = true ;
2828 }
2929
30- if ( argv . config ) {
31- var ext = path . extname ( argv . config ) ;
32- if ( Object . keys ( require . extensions ) . indexOf ( ext ) === - 1 ) {
33- var moduleName = interpret . extensions [ ext ] ;
34- var compiler = require ( moduleName ) ;
35- var register = interpret . register [ moduleName ] ;
36- var config = interpret . configurations [ moduleName ] ;
37- if ( register ) {
38- register ( compiler , config ) ;
39- }
40- }
41- options = require ( path . resolve ( argv . config ) ) ;
30+ var configPath , extname ;
31+ if ( argv . config ) {
32+ configPath = argv . config ;
33+ extname = path . extname ( configPath ) ;
4234 } else {
43- var configPath = path . resolve ( "webpack.config.js" ) ;
44- if ( fs . existsSync ( configPath ) ) {
45- options = require ( configPath ) ;
35+ Object . keys ( interpret . extensions ) . some ( function ( ext ) {
36+ extname = ext ;
37+ configPath = path . resolve ( 'webpack.config' + ext ) ;
38+ return fs . existsSync ( configPath ) ;
39+ } ) ;
40+ }
41+
42+ var moduleName = interpret . extensions [ extname ] ;
43+ if ( moduleName ) {
44+ var compiler = require ( moduleName ) ;
45+ var register = interpret . register [ moduleName ] ;
46+ var config = interpret . configurations [ moduleName ] ;
47+ if ( register ) {
48+ register ( compiler , config ) ;
4649 }
4750 }
51+ options = require ( configPath ) ;
52+
4853 if ( typeof options !== "object" || options === null ) {
4954 console . log ( "Config did not export a object." ) ;
5055 process . exit ( - 1 ) ;
0 commit comments