@@ -145,15 +145,11 @@ async function loadConfig(config, context, configPath, loaderContext) {
145
145
146
146
if ( typeof resultConfig === 'function' ) {
147
147
resultConfig = resultConfig ( patchedContext ) ;
148
- } else {
149
- resultConfig = { ...resultConfig , ...patchedContext } ;
150
148
}
151
149
152
- if ( result . filepath ) {
153
- resultConfig . file = result . filepath ;
150
+ resultConfig . file = result . filepath ;
154
151
155
- loaderContext . addDependency ( result . filepath ) ;
156
- }
152
+ loaderContext . addDependency ( result . filepath ) ;
157
153
158
154
return resultConfig ;
159
155
}
@@ -173,13 +169,24 @@ function getPostcssOptions(loaderContext, config, options = {}) {
173
169
loaderContext . emitError ( error ) ;
174
170
}
175
171
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
+
176
183
const processOptions = {
177
184
// TODO path.resolve
178
185
from : file ,
179
186
to : file ,
180
187
map : false ,
181
- ...config ,
182
- ...options ,
188
+ ...processOptionsFromConfig ,
189
+ ...processOptionsFromOptions ,
183
190
} ;
184
191
185
192
let needExecute = false ;
@@ -194,10 +201,9 @@ function getPostcssOptions(loaderContext, config, options = {}) {
194
201
// eslint-disable-next-line import/no-dynamic-require, global-require
195
202
processOptions . parser = require ( processOptions . parser ) ;
196
203
} catch ( error ) {
197
- // TODO improve
198
204
loaderContext . emitError (
199
205
new Error (
200
- `Loading PostCSS parser failed: ${ error . message } \n\n(@${ file } )`
206
+ `Loading PostCSS " ${ processOptions . parser } " parser failed: ${ error . message } \n\n(@${ file } )`
201
207
)
202
208
) ;
203
209
}
@@ -210,7 +216,7 @@ function getPostcssOptions(loaderContext, config, options = {}) {
210
216
} catch ( error ) {
211
217
loaderContext . emitError (
212
218
new Error (
213
- `Loading PostCSS Stringifier failed: ${ error . message } \n\n(@${ file } )`
219
+ `Loading PostCSS " ${ processOptions . stringifier } " stringifier failed: ${ error . message } \n\n(@${ file } )`
214
220
)
215
221
) ;
216
222
}
@@ -223,7 +229,7 @@ function getPostcssOptions(loaderContext, config, options = {}) {
223
229
} catch ( error ) {
224
230
loaderContext . emitError (
225
231
new Error (
226
- `Loading PostCSS Syntax failed: ${ error . message } \n\n(@${ file } )`
232
+ `Loading PostCSS " ${ processOptions . syntax } " syntax failed: ${ error . message } \n\n(@${ file } )`
227
233
)
228
234
) ;
229
235
}
0 commit comments