Webpack 5:devtool ValidationError,无效的配置对象 [英] Webpack 5: devtool ValidationError, invalid configuration object

查看:12
本文介绍了Webpack 5:devtool ValidationError,无效的配置对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 Webpack 4 迁移到 Webpack 5 时,我在使用带有空值的 devtool 时出错(仅在生产模式下).

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

控制台中的消息:

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?

推荐答案

回答自己的问题!剧透:false.

Answer to own question! Spoiler: false.

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

在 Webpack 4 中,可以使用空字符串对其进行赋值.webpack 5 更加严格.Webpacks 开发工具配置.

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

这篇关于Webpack 5:devtool ValidationError,无效的配置对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆