@@ -145,15 +145,11 @@ async function loadConfig(config, context, configPath, loaderContext) {
145145
146146 if ( typeof resultConfig === 'function' ) {
147147 resultConfig = resultConfig ( patchedContext ) ;
148- } else {
149- resultConfig = { ...resultConfig , ...patchedContext } ;
150148 }
151149
152- if ( result . filepath ) {
153- resultConfig . file = result . filepath ;
150+ resultConfig . file = result . filepath ;
154151
155- loaderContext . addDependency ( result . filepath ) ;
156- }
152+ loaderContext . addDependency ( result . filepath ) ;
157153
158154 return resultConfig ;
159155}
@@ -173,13 +169,24 @@ function getPostcssOptions(loaderContext, config, options = {}) {
173169 loaderContext . emitError ( error ) ;
174170 }
175171
172+ const processOptionsFromConfig = { ...config } ;
173+
174+ // No need them
175+ delete processOptionsFromConfig . plugins ;
176+
177+ const processOptionsFromOptions = { ...options } ;
178+
179+ // No need them
180+ delete processOptionsFromOptions . config ;
181+ delete processOptionsFromOptions . plugins ;
182+
176183 const processOptions = {
177184 // TODO path.resolve
178185 from : file ,
179186 to : file ,
180187 map : false ,
181- ...config ,
182- ...options ,
188+ ...processOptionsFromConfig ,
189+ ...processOptionsFromOptions ,
183190 } ;
184191
185192 let needExecute = false ;
@@ -194,10 +201,9 @@ function getPostcssOptions(loaderContext, config, options = {}) {
194201 // eslint-disable-next-line import/no-dynamic-require, global-require
195202 processOptions . parser = require ( processOptions . parser ) ;
196203 } catch ( error ) {
197- // TODO improve
198204 loaderContext . emitError (
199205 new Error (
200- `Loading PostCSS parser failed: ${ error . message } \n\n(@${ file } )`
206+ `Loading PostCSS " ${ processOptions . parser } " parser failed: ${ error . message } \n\n(@${ file } )`
201207 )
202208 ) ;
203209 }
@@ -210,7 +216,7 @@ function getPostcssOptions(loaderContext, config, options = {}) {
210216 } catch ( error ) {
211217 loaderContext . emitError (
212218 new Error (
213- `Loading PostCSS Stringifier failed: ${ error . message } \n\n(@${ file } )`
219+ `Loading PostCSS " ${ processOptions . stringifier } " stringifier failed: ${ error . message } \n\n(@${ file } )`
214220 )
215221 ) ;
216222 }
@@ -223,7 +229,7 @@ function getPostcssOptions(loaderContext, config, options = {}) {
223229 } catch ( error ) {
224230 loaderContext . emitError (
225231 new Error (
226- `Loading PostCSS Syntax failed: ${ error . message } \n\n(@${ file } )`
232+ `Loading PostCSS " ${ processOptions . syntax } " syntax failed: ${ error . message } \n\n(@${ file } )`
227233 )
228234 ) ;
229235 }
0 commit comments