Skip to content

Commit 855b7df

Browse files
sudo-suhasLinusBorg
authored andcommitted
Document babel target env configuration (vuejs-templates#1144)
1 parent fb33514 commit 855b7df

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [Project Structure](structure.md)
44
- [Build Commands](commands.md)
5+
- [Babel Configuration](babel.md)
56
- [Linter Configuration](linter.md)
67
- [Pre-Processors](pre-processors.md)
78
- [Handling Static Assets](static.md)

docs/babel.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Babel Configuration
2+
3+
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.
4+
5+
> 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.
6+
7+
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).
8+
9+
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`:
10+
11+
```json
12+
{
13+
"...": "...",
14+
"browserslist": [
15+
"> 1%",
16+
"last 2 versions",
17+
"not ie <= 8"
18+
]
19+
}
20+
```
21+
22+
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/[email protected]`](https://github.com/babel/babel/tree/master/packages/babel-preset-env)) and the template will be updated once it is out of beta.

0 commit comments

Comments
 (0)