I was using the version 1.6.2 of this lib and seems after upgrading webpack to version 1.13.* the webpack build started to give me the error:
ERROR in Path must be a string. Received undefined
I could not find really where this problem was occurring. But looks like after upgrading it to latest version 2.19.0 the error disappeared.
This bug was difficult to track down so adding here so others can benefit. After switching to Node v6 I would get the error above. Turns out the offending code was:
var publicPath = typeof compilation.options.output.publicPath !== 'undefined' ?
compilation.mainTemplate.getPublicPath({hash: webpackStatsJson.hash}) :
path.relative(path.dirname(self.options.filename), '.');
When self.options.filename was undefined the plugin would break since Node v6 must have values for path.dirname . A simple solution was to set the filename
new HtmlWebpackPlugin({
template: 'project/app/index.html',
favicon: 'project/app/favicon.ico',
filename: 'index.html',
pkg: getPkg()
})
Thanks Rob! I just ran into the same error and the same solution works for me.
Is it possible that html-webpack-plugin output some more useful error if publicPath is not defined? Maybe an extra check or something like that.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
This bug was difficult to track down so adding here so others can benefit. After switching to Node
v6I would get the error above. Turns out the offending code was:When
self.options.filenamewas undefined the plugin would break since Nodev6must have values forpath.dirname. A simple solution was to set thefilename