Webpack 5: devtool ValidationError, invalid configuration object

别说谁变了你拦得住时间么 提交于 2020-12-09 07:16:20

问题


While migrating from Webpack 4 to Webpack 5 I got an error when using devtool with empty value (only in production mode).

module.exports = {
    devtool: isProd ? '' : 'source-map',
    // entry: ...
    // output: ...
    // module: ...
}

The message in the console:

ValidationError: 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.

Any ideas how to avoid source maps in production mode? What to type in there?


回答1:


Answer to own question! Spoiler: false.

module.exports = {
    devtool: isProd ? false : 'source-map',
}

In Webpack 4 it was possible to value this with an empty string. webpack 5 is more strict. Webpacks devtool configuration.



来源:https://stackoverflow.com/questions/62591440/webpack-5-devtool-validationerror-invalid-configuration-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!