@@ -47,43 +47,43 @@ module.exports = function loader (css, map) {
4747
4848 validateOptions ( require ( './options.json' ) , options , 'PostCSS Loader' )
4949
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
6151
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
6658
67- if ( options . config . ctx ) {
68- rc . ctx . options = options . config . ctx
59+ return option
60+ } )
61+ . length
62+
63+ if ( length ) {
64+ return parseOptions . call ( this , options )
6965 }
70- }
7166
72- const sourceMap = options . sourceMap
67+ const rc = {
68+ path : path . dirname ( file ) ,
69+ ctx : {
70+ file : {
71+ extname : path . extname ( file ) ,
72+ dirname : path . dirname ( file ) ,
73+ basename : path . basename ( file )
74+ } ,
75+ options : { }
76+ }
77+ }
7378
74- Promise . resolve ( ) . then ( ( ) => {
75- const length = Object . keys ( options ) . length
79+ if ( options . config ) {
80+ if ( options . config . path ) {
81+ rc . path = path . resolve ( options . config . path )
82+ }
7683
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 )
84+ if ( options . config . ctx ) {
85+ rc . ctx . options = options . config . ctx
86+ }
8787 }
8888
8989 return postcssrc ( rc . ctx , rc . path , { argv : false } )
0 commit comments