Conflict: Multiple assets emit to the same filename

后端 未结 7 1430
耶瑟儿~
耶瑟儿~ 2020-12-13 11:58

I\'m a webpack rookie who wants to learn all about it. I came across a conflict when running my webpack telling me:

ERROR in chunk html [entry] app.js Confl

7条回答
  •  一生所求
    2020-12-13 12:28

    The same error in a Vue.js project when doing e2e with Karma. The page was served using a static template index.html with /dist/build.js. And got this error running Karma.

    The command to issue Karma using package.json was:

    "test": "cross-env BABEL_ENV=test CHROME_BIN=$(which chromium-browser) karma start --single-run"
    

    The output configuration in webpack.config.js was:

     module.exports = {
      output: {
       path: path.resolve(__dirname, './dist'),
       publicPath: '/dist/',
       filename: 'build.js'
      },
      ...
     }
    

    My solution: inspired by the Evan Burbidge's answer I appended the following at the end of webpack.config.js:

    if (process.env.BABEL_ENV === 'test') {
      module.exports.output.filename = '[name].[hash:8].js'
    }
    

    And then it eventually worked for both page serving and e2e.

提交回复
热议问题