Conflict: Multiple assets emit to the same filename

后端 未结 7 1433
耶瑟儿~
耶瑟儿~ 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条回答
  •  Happy的楠姐
    2020-12-13 12:18

    I had exactly the same problem. The problem seems to occur with the file-loader. The error went away when I removed the html test and included html-webpack-plugin instead to generate an index.html file. This is my webpack.config.js file:

    var path = require('path');
    
    var HtmlWebpackPlugin = require('html-webpack-plugin');
    var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
      template: __dirname + '/app/index.html',
      filename: 'index.html',
      inject: 'body'
    })
    
    module.exports = { 
      entry: {
        javascript: './app/index.js',
      },  
    
      output: {
        filename: 'bundle.js',
        path: __dirname + '/dist'
      },  
    
      module: {
        rules: [
          {   
            test: /\.jsx?$/,
            exclude: [
              path.resolve(__dirname, '/node_modules/')
            ],  
            loader: 'babel-loader'
          },  
        ]   
      },  
    
      resolve: {
        extensions: ['.js', '.jsx', '.json']
      },  
    
      plugins: [HTMLWebpackPluginConfig]
    }

    The html-webpack-plugin generates an index.html file and automatically injects the bundled js file into it.

提交回复
热议问题