webpack详细的错误消息

我正在使用webpack,最近更新了一些软件包(babel,babel-loader,..),并看到webpack输出中的错误。 但是,不知道如何进一步debugging。 该应用程序似乎工作正常。 我尝试了各种debugging选项,但没有得到详细的错误输出。

./node_modules/.bin/webpack --config webpack.config.js --progress --profile --colors --display-error-details --display-reasons --debug NODE_ENV == production : false 6809ms build modules 14ms seal 55ms optimize 30ms hashing 59ms create chunk assets 27ms additional chunk assets 1551ms optimize chunk assets 33ms optimize assets 83ms emit Hash: 5be1a8485c4110c2f837 Version: webpack 1.9.8 Time: 8674ms Asset Size Chunks Chunk Names mww7few.ttf 78.4 kB [emitted] elilql0.png 7.47 kB [emitted] client.js 3.98 MB 0 [emitted] main index.html 130 bytes [emitted] [0] multi main 52 bytes {0} [built] factory:0ms building:3ms = 3ms + 387 hidden modules ERROR in undefined 

我不确定这是什么ERROR in undefined 。 我怀疑加载器的问题,因为我更新了babel-loader但不知道如何知道更多。

@bsr

我最近有这个相同的问题。 事实certificate,这是从HtmlWebpackPlugin。 我忘了通过一个标题

 new HtmlWebpackPlugin({ .... title: 'Title' }), 

在我的模板上,我有这个<title>{%=o.htmlWebpackPlugin.options.title

所以如果你使用HtmlWebpackPlugin,确保你传递了所有的参数。

这是webpack-html-plugin 1.4版本中的一个bug,在1.5版本中被修复

错误的原因是不推荐使用o.htmlWebpackPlugin.assets
您应该使用o.htmlWebpackPlugin.files而不是使用css和清单文件:

 <!DOCTYPE html> <html{% if(o.htmlWebpackPlugin.files.manifest) { %} manifest="{%= o.htmlWebpackPlugin.files.manifest %}"{% } %}> <head> <meta charset="UTF-8"> <title>{%=o.htmlWebpackPlugin.options.title || 'Webpack App'%}</title> {% if (o.htmlWebpackPlugin.files.favicon) { %} <link rel="shortcut icon" href="{%=o.htmlWebpackPlugin.files.favicon%}"> {% } %} {% for (var css in o.htmlWebpackPlugin.files.css) { %} <link href="{%=o.htmlWebpackPlugin.files.css[css] %}" rel="stylesheet"> {% } %} </head> <body> {% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %} <script src="{%=o.htmlWebpackPlugin.files.chunks[chunk].entry %}"></script> {% } %} </body> </html> 

不过还有更简单的方法。
webpack-html-plugin 1.3+具有将所有资源(CSS,图标,JavaScript和清单文件)注入到模板中的function。 所以你的configuration可能是这样的:

 new HtmlWebpackPlugin({ inject: true, template: 'template.html', title: 'Custom template', }) 

和模板:

 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>{%=o.htmlWebpackPlugin.options.title || 'Webpack App'%}</title> </head> <body> </body> </html> 

如果有人得到这个问题,这不是一个问题,htmlWebpackPlugin,实际的问题是在Webpack本身并没有提供正确的错误。

显然这个PR试图解决它

https://github.com/webpack/webpack/pull/1146

我们有我们使用的插件,那些是string错误。 然而,错误重新载入

错误未定义,这是没有什么帮助。 现在我们实际上得到了我们需要的错误报告。

Stats现在错误报告捕获string错误。 一些插件似乎不遵守错误报告的规则。 然而,这使得debugging用户的噩梦。 因此,string应该被允许。