如何在Webpack中启用调试模式?

时间:2015-12-07 20:31:42

标签: javascript webpack

我正在尝试在image-loader中使用bypassOnDebug选项,这意味着我需要将webpack置于“调试模式”(根据图像加载器文档)。

使用dev服务器时是否自动处于调试模式,还是需要在webpack配置中指定?

如果我需要指定它,请提供代码示例吗?

1 个答案:

答案 0 :(得分:51)

Webpack 2& 3

顶级配置上的debug属性不仅已弃用,而且无效。

相反,您必须在每个加载器级别配置它,正如您使用现在无效的The 'debug' property was removed in webpack 2. Loaders should be updated to allow passing this option via loader options in module.rules. Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode: plugins: [ new webpack.LoaderOptionsPlugin({ debug: true }) ] 顶级属性集运行时显示的这个非常友好的错误消息所描述的那样:

debug

The docs also have similar information.

注意

我发现将我的所有加载器更新为最新版本,然后逐个尝试它们以查看它们是否接受webpack.LoaderOptionsPlugin选项有点重量级,考虑到我只想将它们设置为全部为true或全部为false取决于配置。

如果这是您的情况,我可以确认使用<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" > <CardView> <CardView> <CardView> </LinearLayout> 是最简单的方法。它适用于所有新旧装载机。