First of all, thanks for this plugin! This rocks, and therefore you rock!
While looking at the issues, I saw #6 which was exactly my problem, but on example you gave, you added the publicPath manually to the HTML.
This is fine for most projects, however is quite troublesome if your website is going to be deployed on multiple domains and the publicPath changes with each configuration.
Is it possible to expose the publicPath to the templating somehow?
Thanks
Cheers, glad you like the plugin.
The options object that you pass into the plugin is available in the template, so you could expose the public path through that. Not the cleanest solution and I'll probably add a better way to do this, but it should work. Here is an example:
webpack.config.js
var myPublicPath = '/public/';
var webpackConfig = {
output: {
publicPath: myPublicPath
}
plugins: [
new HtmlWebpackPlugin({
template: './my_index.html',
publicPath: myPublicPath
})
]
};
my_index.html:
<link rel="stylesheet" href="{%=o.htmlWebpackPlugin.options.publicPath%}{%=o.webpack.assetsByChunkName.client[1]%}"/>
That's exactly how I did. :)
But it would be nice not having to duplicate that option (webpack config + HTMLWebpack config), when several people work in the project, someone ought to forget about the duplicated option.
@Couto see above PR.
Great work! I will test those new features later at night. Thanks :+1:
Fixed in 6ae0e8520248fae25439fcd012e87e29100cf1b0. You can get a hold of the publicPath through {%=o.webpackConfig.output.publicPath%}.
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
Fixed in 6ae0e8520248fae25439fcd012e87e29100cf1b0. You can get a hold of the publicPath through
{%=o.webpackConfig.output.publicPath%}.