What is Babel?
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.
Here are the main things Babel can do for you:
- Transform syntax
- Polyfill features that are missing in your target environment (through @babel/polyfill)
- Source code transformations (codemods)
Configuration
Bable can be configured much like or tools such as ESLint and Prettier. Out of the box, any vue-cli generated applications will have Babel setup and configured at a minimum level. We have setup our own babel config to use within our applications.
// babel.config.js
module.exports = {
presets: [['@vue/app', { useBuiltIns: 'entry' }]]
}
// .browserslistrc
> 0.1% in US
last 2 versions
not dead