简体   繁体   中英

ERROR in Conflict: Multiple assets emit different content to the same filename

I'm trying to upgrade to the latest webpack version, but now getting these error messages when using webpack serve --hot --mode development --port 3000

ERROR in Conflict: Multiple assets emit different content to the same filename ./A-50a08b634ba9289cefda.map

ERROR in Conflict: Multiple assets emit different content to the same filename ./B-18c50412514091296e3d.map

ERROR in Conflict: Multiple assets emit different content to the same filename ./C-00a60de5f5a500386d5f.map

ERROR in Conflict: Multiple assets emit different content to the same filename ./D-17887f8cd059fe724e29.map

ERROR in Conflict: Multiple assets emit different content to the same filename ./E-315a596abbc5432ec621.map

ERROR in Conflict: Multiple assets emit different content to the same filename ./F-a5125e3b3128b127b17e.map

This is my webpack config file:

const webpack = require('webpack');

module.exports = {
  entry: {
    A: './src/main/javascript/entrypoints/A.js',
    B: './src/main/javascript/entrypoints/B.js',
    C: './src/main/javascript/entrypoints/C.js',
    D: './src/main/javascript/entrypoints/D.js',
    E: './src/main/javascript/entrypoints/E.js',
    F: './src/main/javascript/entrypoints/F.js'
  },
  module: {
    rules: [{
      test: /\.js$/,
      exclude: /node_modules/,
      use: {
        loader: 'babel-loader',
        options: {
            presets: ['@babel/react', '@babel/preset-env']
        }
      }
    },{
        test: /css\/global\/.*\.css$/,
        use: [
            {
                loader: 'style-loader'
            }, {
                loader: 'css-loader',
                options: {
                    url: false
                }
            }
        ],
    },{
        test: /css\/module\/.*\.css$/,
        loader: "style-loader"
     },{
        test: /css\/module\/.*\.css$/,
        loader: "css-loader",
        options: {
          url: false,
          modules: {
            localIdentName: '[name]__[local]___[hash:base64:5]'
          }
        }
    }
    ]
  },
  resolve: {
    extensions: ['.js', '.json']
  },
  output: {
    path: __dirname + '/src/main/resources/static/js',
    publicPath: '/js',
    filename: '[name].js',
    sourceMapFilename: './[name]-[chunkhash].map'
  },
  devtool: 'source-map'
};

and this is my package.json:

{
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/preset-env": "^7.12.11",
    "@babel/preset-react": "^7.12.10",
    "@hot-loader/react-dom": "^17.0.1+4.13.0",
    "babel-loader": "^8.2.2",
    "babel-preset-react": "^6.24.1",
    "css-loader": "5.0.1",
    "eslint": "^2.9.0",
    "source-map-explorer": "^2.5.2",
    "style-loader": "^2.0.0",
    "webpack": "^5.13.0",
    "webpack-cli": "^4.3.1",
    "webpack-dev-server": "^3.11.1"
  },
  "dependencies": {
    "babel-polyfill": "^6.26.0",
    "react": "^16.9.0",
    "redux": "^4.0.4",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0"
    ...
  }
}

I'm probably doing something silly. Any suggestions on what I might be doing wrong?

UPDATE: it seems if I use devtool: 'eval-source-map' instead of 'source-map' the errors no longer occur.

This has to do with loaders and/or plugins collision as they try to output the same file(s). It doesn't just apply sourcemaps , just for future reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM