Flesh out readme (#410)

This commit is contained in:
Stephen Scott 2017-09-13 11:29:30 -06:00 committed by Brian Ng
parent 7c70b27b53
commit f3fe5001e6

View File

@ -1,12 +1,12 @@
# babel-preset-env [![npm](https://img.shields.io/npm/v/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![travis](https://img.shields.io/travis/babel/babel-preset-env/master.svg)](https://travis-ci.org/babel/babel-preset-env) [![npm-downloads](https://img.shields.io/npm/dm/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![codecov](https://img.shields.io/codecov/c/github/babel/babel-preset-env/master.svg?maxAge=43200)](https://codecov.io/github/babel/babel-preset-env)
> A Babel preset that can automatically determine the Babel plugins and polyfills you need based on your supported environments.
> A Babel preset that gives you everything standardized in [ES2015+](https://github.com/tc39/proposals/blob/master/finished-proposals.md), and can automatically determine the Babel plugins and polyfills you need based on your supported environments.
```sh
npm install babel-preset-env --save-dev
```
Acts as a replacement for preset-es2015,16,17,latest
Without any configuration options, babel-preset-env behaves exactly the same as babel-preset-latest (or babel-preset-es2015, babel-preset-es2016, and babel-preset-es2017 together).
```json
{
@ -14,7 +14,9 @@ Acts as a replacement for preset-es2015,16,17,latest
}
```
You can target specific versions with browserslist
You can also configure it to only include the polyfills and transforms needed for the browsers you support. Compiling only what's needed can make your bundles smaller and your life easier.
This example only includes the polyfills and code transforms needed for the last two versions of each browser, and versions of Safari greater than or equal to 7. We use [browserslist](https://github.com/ai/browserslist) to parse this information, so you can use [any valid query format supported by browserslist](https://github.com/ai/browserslist#queries).
```json
{
@ -28,7 +30,21 @@ You can target specific versions with browserslist
}
```
Or even the current (running) version of Node
Similarly, if you're targeting Node.js instead of the browser, you can configure babel-preset-env to only include the polyfills and transforms necessary for a particular version:
```json
{
"presets": [
["env", {
"targets": {
"node": "6.10"
}
}]
]
}
```
For convenience, you can use `"node": "current"` to only include the necessary polyfills and transforms for the Node.js version that you use to run Babel:
```json
{