Skip to content

Commit

Permalink
Document babel target env configuration (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-suhas authored and LinusBorg committed Dec 9, 2017
1 parent d771d1e commit caa259a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [Project Structure](structure.md)
- [Build Commands](commands.md)
- [Babel Configuration](babel.md)
- [Linter Configuration](linter.md)
- [Pre-Processors](pre-processors.md)
- [Handling Static Assets](static.md)
Expand Down
22 changes: 22 additions & 0 deletions docs/babel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Babel Configuration

This boilerplate uses [`babel-preset-env`](https://www.npmjs.com/package/babel-preset-env) for configuring babel. You can read more about it here - http://2ality.com/2017/02/babel-preset-env.html.

> A Babel preset that compiles ES2015+ down to ES5 by automatically determining the Babel plugins and polyfills you need based on your targeted browser or runtime environments.
It uses [`browserslist`](https://github.com/ai/browserslist) to parse this information, so we can use any [valid query format supported by `browserslist`](https://github.com/ai/browserslist#queries).

However there is a caveat. `browserslist` recommends defining the target in a common place like `package.json` or in a `.browserslistrc` config file. This allows tools like [`autoprefixer`](https://github.com/postcss/autoprefixer) and [`eslint-plugin-compat`](https://github.com/amilajack/eslint-plugin-compat) to share the config. For this template, `browserslist` is configured in the `package.json`:

```json
{
"...": "...",
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
```

But the latest stable release of `babel-preset-env`, `v1.6.1` does not support loading the config from `package.json`. So the target environment is repeated in `.babelrc`. If you wish to change your target environment, please be sure to update both `package.json` and `.babelrc`. Note that this has been fixed in the beta version([`@babel/preset-env@7.0.0-beta.34`](https://github.com/babel/babel/tree/master/packages/babel-preset-env)) and the template will be updated once it is out of beta.

0 comments on commit caa259a

Please sign in to comment.