scottcharlesworth / laravel-mix-polyfill

A Laravel Mix extension to include polyfills by using Babel, core-js, and regenerator-runtime
MIT License
50 stars 7 forks source link

Why does this module exist? #21

Closed bert-w closed 4 years ago

bert-w commented 4 years ago

I was looking around for some Babel polyfill support in Laravel-Mix, but then I found out I already managed to fix this in another project. You can simply use a .babelrc file and your webpack.mix.js will pick it up. It is supported by default.

Contents of .babelrc:

{
    "presets": [
        [
            "@babel/preset-env",
            {
                "useBuiltIns": "usage",
                "corejs": 3
            }
        ]
    ]
}

You can then assign targets using a .browserslistrc file, or just add a "targets":{...} key next to the useBuiltIns key above.

scottcharlesworth commented 4 years ago

If you know how to use .babelrc then that's a solution. This extension is just designed to make it easier, or for people who just want to have everything in their webpack.mix.js. I like being able to add .polyfill() to the mix chain and know everything is taken care of.

Each to their own 😊