-
-
Notifications
You must be signed in to change notification settings - Fork 75
Add env
option to control setting the browserslist environment
#1012
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
Conversation
Sometimes you have multiple browserslist environments. This commit adds an env option to allow you to specify which environment you would like to read from, and passes that information into browserslist and autoprefixer's `env` options. This is like using the BROWSERSLIST_ENV environment variable, except it can be modified at runtime. See Babel's `browserslistEnv` for a similar idea but for Babel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution @BPScott 🎉
Can you take a look at my review comments?
This change will not rollout soon because we are in the middle of changing the license to MIT-0.
We first want to migrate to the new license and gather feedback on that change.
https://preset-env.cssdb.org/blog/license-change/
It will be more complex to do a rollback of the license change if we also have feature changes :)
Thanks for the feedback @romainmenke, I'll address all those. In particular thank you for the docs suggestions, I wasn't sure how to to best teach this in the docs. I wasn't confident regarding how to reframe/discourage the usage of Happy to wait for a bit for the licence changes to settle, I totally appreciate the idea of avoiding awkwardness from mixing license and code changes in a single release. When digging through the postcss-load-config docs I found that |
PR comments addressed. I think the last remaining things from my side are:
|
I actually think it is better that these overlap. It also requires a manual step to connect these two. I also think it is valuable to have the same option name as There will be small number of people who do not understand how the tools work and who are doing overly complicated setups. For them it will backfire, but I also think this is a good thing. It will force them to halt and either do more research or to reach out to others who understand the tooling better. TL;DR; it will work intuitively for almost everyone if we use
I think the wiki is a good place to add more in depth docs. The wiki is good place to explain things in detail without exploding the I personally don't think there is an immediate need for this, but I am also sure it will help some to have more docs.
No, I think you found every important bit 😄
The code you found is configuration for two things :
I've made a small adjustment and updated the I've also made another tweak to this PR.
I've also updated the documentation to reflect this. Thoughts on this? |
Excellent point that I got so wrapped up it my need of "I have 2 production builds that target broad support vs recent browsers and we do user-agent sniffing to send recent browsers a less-aggressively transpiled build" that I forgot that my use-case is niche. I like the framing that if you have a second browserslist environment then it will very likely be I'm happy to leave the naming as it is :)
Reading browserslist's js api docs it stats "If a query is missing, Browserslist will look for a config file". Thus I believe if both Because of that I left out explicitly unsetting it originally, but I'm ok with explicitly unsetting Adding the docs to call this out that Thanks for the feedback and additions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you again for this @BPScott 🎉
@BPScott This was just released as part of |
Fantastic, thank you @romainmenke! |
Sometimes you have multiple browserslist environments that you'd like to compile for. This PR adds an
env
option topostcss-preset-env
to allow you to specify which browserslist environment you would like to read from, and passes that information into browserslist'senv
and autoprefixer'senv
options.This is like using the
BROWSERSLIST_ENV
environment variable, except at a function call level rather than per-process. See Babel'sbrowserslistEnv
option for a similar idea.This allows you to have a
.browserslistrc
that looks likeand then by you can specify
env: 'production'
orenv: 'evergreen'
to pick which set of browsers you would like to target