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

laravel mix 6 support? #32

Closed TheSnip3r closed 3 years ago

TheSnip3r commented 3 years ago

It seems that it doesn't support mix 6. would you support it please?

scottcharlesworth commented 3 years ago

I will take a look over the next 24 hours and see what needs to be done.

scottcharlesworth commented 3 years ago

@TheSnip3r would you be able to add the following to your webpack.mix.js:

mix.extend('addTargets', function(webpackConfig) {
    webpackConfig.target = ['web', 'es5'];
});

And then add .addTargets() to the end of your chain.

For example:

const mix = require('laravel-mix');

require('laravel-mix-polyfill');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel applications. By default, we are compiling the CSS
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.extend('addTargets', function(webpackConfig) {
    webpackConfig.target = ['web', 'es5'];
});

mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css', [
        //
    ])
    .polyfill()
    .addTargets();

It would help to confirm I've found the issue.

TheSnip3r commented 3 years ago

@scottcharlesworth Sorry maybe i didn't make myself clear. I'm not able to check as i cannot install it on Laravel Mix 6. I think the reason is this:

"peerDependencies": {
    "laravel-mix": "^4.0.0 || ^5.0.0"
  }
scottcharlesworth commented 3 years ago

@TheSnip3r Apologies, I assumed you had upgraded from Laravel Mix 5. I think you can bypass dependency checking by adding the following directly to your package.json, and running npm install or yarn install:

"laravel-mix-polyfill": "^2.0.0",
TheSnip3r commented 3 years ago

Thanks, it worked now and I don't know why! I tried it before and it displayed the error of dependency version for Mix "^4.0.0 || ^5.0.0". However, it would be better to update this dependency.

scottcharlesworth commented 3 years ago

@TheSnip3r v3.0.0 has been released with Laravel v6 support.

Thank you for bringing it to my attention.