jantimon/html-webpack-plugin

`templateParameters` not working when running in webpack dev server with `output.publicPath` specified

SevenOutman opened this issue ยท 4 comments

Current behaviour ๐Ÿ’ฃ

When output.publicPath is specified in webpack configuration and running webpack dev server, the html-webpack-plugin won't populate template parameter placeholders in the template file.

Expected behaviour โ˜€๏ธ

Template parameters getting populated correctly.

Reproduction Example ๐Ÿ‘พ

Reproduction can be found in this repository https://github.com/SevenOutman/html-webpack-plugin-template-parameter-repro

Environment ๐Ÿ–ฅ

Node.js v16.13.1
darwin 21.5.0
8.1.2
html-webpack-plugin-template-parameter-repro@ /Users/doma/Developer/html-webpack-plugin-template-parameter-repro
โ”œโ”€โ”ฌ html-webpack-plugin@5.5.0
โ”‚ โ””โ”€โ”€ webpack@5.72.1 deduped
โ”œโ”€โ”ฌ webpack-cli@4.9.2
โ”‚ โ”œโ”€โ”ฌ @webpack-cli/configtest@1.1.1
โ”‚ โ”‚ โ””โ”€โ”€ webpack@5.72.1 deduped
โ”‚ โ””โ”€โ”€ webpack@5.72.1 deduped
โ”œโ”€โ”ฌ webpack-dev-server@4.9.0
โ”‚ โ”œโ”€โ”ฌ webpack-dev-middleware@5.3.3
โ”‚ โ”‚ โ””โ”€โ”€ webpack@5.72.1 deduped
โ”‚ โ””โ”€โ”€ webpack@5.72.1 deduped
โ””โ”€โ”ฌ webpack@5.72.1
  โ””โ”€โ”ฌ terser-webpack-plugin@5.3.1
    โ””โ”€โ”€ webpack@5.72.1 deduped

html-webpack-plugin-template-parameter-repro@ /Users/doma/Developer/html-webpack-plugin-template-parameter-repro
โ””โ”€โ”€ html-webpack-plugin@5.5.0

@SevenOutman That is a funny situation, there is no bugs, by default we have static: "/public/" directory for static files, but you have the interpolated HTML file in dist and index.html template in static, so dev server handle public/index.html, but it is a template, so just set (you can use CLI - --static ./dist):

devServer: {
  static: path.resolve(__dirname, "dist")
},

We even have:

<i> [webpack-dev-server] Content not from webpack is served from '/home/akait/IdeaProjects/html-webpack-plugin-template-parameter-repro/public' directory

๐Ÿ˜„

@SevenOutman That is a funny situation, there is no bugs, by default we have static: "/public/" directory for static files, but you have the interpolated HTML file in dist and index.html template in static, so dev server handle public/index.html, but it is a template, so just set (you can use CLI - --static ./dist):

I'll see if it works for me later, thanks!

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!