Conflict: Multiple assets emit to the same filename

863
February 10, 2017, at 09:06 AM

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 Conflict: Multiple assets emit to the same filename app.js

What should I do to avoid the conflict?

This is my webpack.config.js:

module.exports = { 
  context: __dirname + "/app", 
 
  entry: { 
    'javascript': "./js/app.js", 
    'html': "./index.html", 
  }, 
  output: { 
    path: __dirname + "/dist", 
    filename: "app.js", 
  }, 
  resolve: { 
    extensions: ['.js', '.jsx', '.json'] 
  }, 
  module: { 
    loaders: [ 
      { 
        test: /\.jsx?$/, 
        exclude: /node_modules/, 
        loaders: ["babel-loader"] 
      }, 
      { 
        test: /\.html$/, 
        loader: "file-loader?name=[name].[ext]", 
      } 
    ] 
  } 
};

Answer 1

i'm not quite familiar with your approach so I'll show you a common way to help you out.

First of all, on your output, you are specifying the filename to app.js which makes sense for me that the output will still be app.js. If you want to make it dynamic, then just use "filename": "[name].js".

The [name] part will make the filename dynamic for you. That's the purpose of your entry as an object. Each key will be used as a name in replacement of the [name].js.

And second, you can use the html-webpack-plugin. You don't need to include it as a test.

READ ALSO
javascript regex for 2 possible values

javascript regex for 2 possible values

I'm having trouble coming up with a regex to accept two possible values

126
Angular ng-file-upload: Why is my form data is truncated?

Angular ng-file-upload: Why is my form data is truncated?

I have a form that needs to POST input data along with filesI am currently using danialfarid/ng-file-upload to handle the uploads

85
Trigger all browser events using dispatchEvent

Trigger all browser events using dispatchEvent

I'm thinking about building a tool that converts all browser events (either native dom events likeclick() or jQuery events) to a standard form

96
Access children of items inside a Lightning Component

Access children of items inside a Lightning Component

I have my lightning component set up like this:

104