@@ -47,43 +47,47 @@ module.exports = function loader (css, map) {
47
47
48
48
validateOptions ( require ( './options.json' ) , options , 'PostCSS Loader' )
49
49
50
- const rc = {
51
- path : path . dirname ( file ) ,
52
- ctx : {
53
- file : {
54
- extname : path . extname ( file ) ,
55
- dirname : path . dirname ( file ) ,
56
- basename : path . basename ( file )
57
- } ,
58
- options : { }
59
- }
60
- }
50
+ const sourceMap = options . sourceMap
61
51
62
- if ( options . config ) {
63
- if ( options . config . path ) {
64
- rc . path = path . resolve ( options . config . path )
65
- }
52
+ Promise . resolve ( ) . then ( ( ) => {
53
+ const length = Object . keys ( options )
54
+ . filter ( ( option ) => {
55
+ // if (option === 'exec') return
56
+ if ( option === 'config' ) return
57
+ if ( option === 'sourceMap' ) return
66
58
67
- if ( options . config . ctx ) {
68
- rc . ctx . options = options . config . ctx
59
+ return option
60
+ } )
61
+ . length
62
+
63
+ console . log ( 'Parse Options' )
64
+
65
+ if ( length ) {
66
+ return parseOptions . call ( this , options )
69
67
}
70
- }
71
68
72
- const sourceMap = options . sourceMap
69
+ console . log ( 'Load Config' )
70
+
71
+ const rc = {
72
+ path : path . dirname ( file ) ,
73
+ ctx : {
74
+ file : {
75
+ extname : path . extname ( file ) ,
76
+ dirname : path . dirname ( file ) ,
77
+ basename : path . basename ( file )
78
+ } ,
79
+ options : { }
80
+ }
81
+ }
73
82
74
- Promise . resolve ( ) . then ( ( ) => {
75
- const length = Object . keys ( options ) . length
83
+ if ( options . config ) {
84
+ if ( options . config . path ) {
85
+ rc . path = path . resolve ( options . config . path )
86
+ }
76
87
77
- // TODO
78
- // Refactor
79
- if ( ! options . config && ! sourceMap && length ) {
80
- return parseOptions . call ( this , options )
81
- } else if ( options . config && ! sourceMap && length > 1 ) {
82
- return parseOptions . call ( this , options )
83
- } else if ( ! options . config && sourceMap && length > 1 ) {
84
- return parseOptions . call ( this , options )
85
- } else if ( options . config && sourceMap && length > 2 ) {
86
- return parseOptions . call ( this , options )
88
+ if ( options . config . ctx ) {
89
+ rc . ctx . options = options . config . ctx
90
+ }
87
91
}
88
92
89
93
return postcssrc ( rc . ctx , rc . path , { argv : false } )
0 commit comments