laravel-mix: Module build failed: Error: Duplicate plugin/preset detected.

  • Laravel Mix Version: 3.0.0 and 4.0.0.beta
  • Node Version: 10
  • NPM Version: 5
  • OS: macos 10.14

Description:

Compile error

ERROR in ./resources/assets/admin/app.js
Module build failed: Error: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]

I found that webpack-merge cannot remove duplicate configurations, How can I solve this?

Steps To Reproduce:

Because I need to use “useBuiltIns”: “usage” to handle compatibility, Operating under laravel

  1. Add the following code in .babelrc
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "modules": false,
        "targets": {
          "browsers": [
            "> 2%"
          ]
        },
        "useBuiltIns": "usage",
        "forceAllTransforms": true
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-syntax-dynamic-import",
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}
  1. npm run dev

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 26 (7 by maintainers)

Most upvoted comments

Hmm - you’re right. I guess my test was missing a check for duplicates. I think I’ve fixed this now.

https://github.com/JeffreyWay/laravel-mix/commit/83f5052eb32c498a90edace47402d66eaf80f4b7

A 3.x update with this fix would be useful, please? I can’t use 4.x due to dynamic imports. Otherwise, I’ll have to downgrade back to 2.x with Babel 6 instead of 7.

@JeffreyWay Thank you, the test is successful, you can publish a version 3.x of?

@james-brndwgn Use the webpack manifest plugin and [contenthash] in the output filename. 😃

Okay, this is fixed. We now use a smarter merging strategy, so that your nested Babel config overrides Mix’s. This will be included as part of Mix v4.

https://github.com/JeffreyWay/laravel-mix/commit/2c90afc0005d7863c52d7581f9170ef06b2c4349