1

我正在尝试升级到最新的 webpack 版本,但现在使用时收到这些错误消息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

这是我的 webpack 配置文件:

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'
};

这是我的 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"
    ...
  }
}

我可能在做一些愚蠢的事情。关于我可能做错了什么的任何建议?

更新:如果我使用 devtool: 'eval-source-map' 而不是 'source-map' 似乎不再发生错误。

4

1 回答 1

0

这与加载器和/或插件冲突有关,因为它们试图输出相同的文件。它不只是应用sourcemaps,仅供将来参考。

于 2021-02-25T17:58:50.123 回答