配置webpack打包报错:
Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.- configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$". BREAKING CHANGE since webpack 5: The devtool option is more strict. Please strictly follow the order of the keywords in the pattern百度说是版本不兼容问题,就是假设你webpack版本是5,但是用到的插件版本还是4,不兼容webpack5。
所以此时你可以选择降级webpack,
npm install webpack@4.41.5
之后又报错:
TypeError: Cannot read properties of undefined (reading ‘tap’)
还是百度的答案:将webpack降级后,html-webpack-plugin需要和webpack保持同一个版本,这里我执行了:npm install html-webpack-plugin@4.41.5会报错,去了npm官网,只需要@4就行了
npm i --save-dev html-webpack-plugin@4
最后解决了问题。