- Published on
Babel
- Author
- Name
- Igor Cangussu
- @Goduu_
Babel is a JavaScript compiler and "transpiler". Given modern JavaScript syntax as input, babel is able to transform it to compatible code that can run in (almost) any browser.
Configuring with Webpack
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
],
},
}
Configuring babel for React
#react
npm i @babel/core babel-loader @babel/preset-env @babel/preset-react --save-dev
// babel.config.json
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}