How to modify babel-preset-env configuration in laravel-mix

1k views Asked by At
  • Laravel Mix Version: 1.4.2
  • Node Version (node -v): v8.4.0
  • NPM Version (npm -v): 5.3.0
  • OS: Mac

Description:

In src/config.js there is:

babel: function () { let options = {};

    tap(Mix.paths.root('.babelrc'), babelrc => {
        if (File.exists(babelrc)) {
            options = JSON.parse(File.find(babelrc).read());
        }
    });

    let defaultOptions = {
        cacheDirectory: true,
        presets: [
            ['env', {
                'modules': false,
                'targets': {
                    'browsers': ['> 2%'],
                    uglify: true
                }
            }]
        ]
    };

    if (this.react) {
        defaultOptions.presets.push('react');
    }

    return webpackMerge.smart(defaultOptions, options);
},

Steps To Reproduce:

In my .babelrc I have

{
  "presets": [
    ["env", {
        "targets": {
            "browsers": ["> 5%"],
            "uglify": false
        }
    }]
  ]
}

However, this is just concatenating this as another 'env' preset and it isn't being used. How can I modify the original env preset?

0

There are 0 answers