Ensure options are passed to plugins when using postcss.config.js #170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a
postcss.config.jsis used (instead of passing apluginsarray), the PostCSS options passed to gulp-postcss are ignored by all PostCSS plugins.If you look at the default export for
postcs-load-config, you'll see:where
ConfigContextis defined as:and
ProcessOptions, defined in PostCSS, contains these keys:from,to,parser,stringifier,syntax,map.TLDR; the first argument to
postcssrc()is a single object withContextand PostCSS'ProcessOptionsmerged together.But
gulp-postcssis callingpostcssrc()with{ file: file, options: contextOptions }as its first argument. I noticed 2 things with this:fileis not a part ofContextorProcessOptions. But I see thatpostcss-load-config's README says:It looks like that is what gulp-postcss is doing with the additional
fileproperty. HOWEVER, theProcessOptionsare not passed as a part of the ctx properties; instead they are put into a sub-property,ctx.options. That means the options passed togulp-postcssare ignored by all PostCSS plugins since they are not where they are supposed to be.