Ensure options are passed to plugins when using postcss.config.js#170
Merged
w0rm merged 6 commits intopostcss:mainfrom Jan 12, 2024
Merged
Ensure options are passed to plugins when using postcss.config.js#170w0rm merged 6 commits intopostcss:mainfrom
w0rm merged 6 commits intopostcss:mainfrom
Conversation
9af131c to
cf7f8cf
Compare
Contributor
Author
|
I discovered this while using |
cf7f8cf to
a4a8778
Compare
Contributor
Author
|
I consider passing the options in as module.exports = function (ctx) {
var file = ctx.file;
var options = ctx.options;I've fixed the bug and the above code snippet, but I've also added 1cd7e21 to ensure backwards compatibility with 9.0.0 if you want to release a 9.0.1 after this bugifx. That commit should be reverted before a 10.0.0 release is made, IMO. |
047c2fe to
ad5bcaf
Compare
4b72a3d to
5b98eae
Compare
Member
|
Thanks, I guess this is backwards compatible, so I am going to just merge this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.