-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure options are passed to plugins when using postcss.config.js #170
Conversation
9af131c
to
cf7f8cf
Compare
I discovered this while using |
cf7f8cf
to
a4a8778
Compare
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
Thanks, I guess this is backwards compatible, so I am going to just merge this. |
If a
postcss.config.js
is used (instead of passing aplugins
array), 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
ConfigContext
is 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 withContext
and PostCSS'ProcessOptions
merged together.But
gulp-postcss
is callingpostcssrc()
with{ file: file, options: contextOptions }
as its first argument. I noticed 2 things with this:file
is not a part ofContext
orProcessOptions
. But I see thatpostcss-load-config
's README says:It looks like that is what gulp-postcss is doing with the additional
file
property. HOWEVER, theProcessOptions
are 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-postcss
are ignored by all PostCSS plugins since they are not where they are supposed to be.