Laravel-mix: Suggestion: A switch to forcedly override default config

Created on 12 Jul 2018  Â·  5Comments  Â·  Source: JeffreyWay/laravel-mix

Description:

example:

const mix = require('laravel-mix')
const enforce = true  // cover default babel config

mix.babelConfig({
    plugins: []
}, enforce)

if enforce equal true ,mix.babelConfig will not merge default config, but just replace it.
Is it feasible?

stale

Most helpful comment

I'd also like to have this kind of feature.
Babel isn't as configurable as it should be in my opinion.

I have a custom .babelrc where I'd like to target specific browsers.
For example:

{
  "presets": [
    [
      "env",
      {
        "modules": false,
        "targets": {
          "chrome": 66
        }
      }
    ]
  ]
}

The merge generates a config that looks like this:

{
  "cacheDirectory": true,
  "presets": [
    [
      "env",
      {
        "modules": false,
        "targets": {
          "browsers": [
            "> 2%"
          ],
          "uglify": true
        }
      }
    ],
    [
      "env",
      {
        "modules": false,
        "targets": {
          "chrome": 66
        }
      }
    ]
  ],
  "plugins": [
    "transform-object-rest-spread",
    [
      "transform-runtime",
      {
        "polyfill": false,
        "helpers": false
      }
    ]
  ]
}

which effectively makes the custom config useless for this use case.

All 5 comments

I'd also like to have this kind of feature.
Babel isn't as configurable as it should be in my opinion.

I have a custom .babelrc where I'd like to target specific browsers.
For example:

{
  "presets": [
    [
      "env",
      {
        "modules": false,
        "targets": {
          "chrome": 66
        }
      }
    ]
  ]
}

The merge generates a config that looks like this:

{
  "cacheDirectory": true,
  "presets": [
    [
      "env",
      {
        "modules": false,
        "targets": {
          "browsers": [
            "> 2%"
          ],
          "uglify": true
        }
      }
    ],
    [
      "env",
      {
        "modules": false,
        "targets": {
          "chrome": 66
        }
      }
    ]
  ],
  "plugins": [
    "transform-object-rest-spread",
    [
      "transform-runtime",
      {
        "polyfill": false,
        "helpers": false
      }
    ]
  ]
}

which effectively makes the custom config useless for this use case.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

So, this is the end?

The latest version of Mix includes improved Babel config merging.

Great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefensuhat picture stefensuhat  Â·  3Comments

amin101 picture amin101  Â·  3Comments

hasnatbabur picture hasnatbabur  Â·  3Comments

rlewkowicz picture rlewkowicz  Â·  3Comments

Micaso picture Micaso  Â·  3Comments