@@ -27,24 +27,34 @@ 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 , ext ;
31+ if ( argv . config ) {
32+ configPath = argv . config ;
33+ ext = path . extname ( configPath ) ;
4234 } else {
43- var configPath = path . resolve ( "webpack.config.js" ) ;
44- if ( fs . existsSync ( configPath ) ) {
45- options = require ( configPath ) ;
35+ var found = Object . keys ( interpret . extensions ) . some ( function ( extname ) {
36+ ext = extname ;
37+ configPath = path . resolve ( 'webpack.config' + ext ) ;
38+ return fs . existsSync ( configPath ) ;
39+ } ) ;
40+
41+ if ( ! found ) {
42+ configPath = 'webpack.config.js' ;
43+ ext = '.js' ;
4644 }
4745 }
46+
47+ var moduleName = interpret . extensions [ ext ] ;
48+ if ( moduleName ) {
49+ var compiler = require ( moduleName ) ;
50+ var register = interpret . register [ moduleName ] ;
51+ var config = interpret . configurations [ moduleName ] ;
52+ if ( register ) {
53+ register ( compiler , config ) ;
54+ }
55+ }
56+ options = require ( configPath ) ;
57+
4858 if ( typeof options !== "object" || options === null ) {
4959 console . log ( "Config did not export a object." ) ;
5060 process . exit ( - 1 ) ;
0 commit comments