Dev server is not rebuilding the HTML file when using templating
Miodec opened this issue ยท 0 comments
Miodec commented
Current behaviour ๐ฃ
Im using HTML templating to reduce the size of my HTML file. If I save index.html
, the webpack dev server correctly rebuilds the file. However, if I save one of the template files, this does not happen.
Expected behaviour โ๏ธ
The HTML file should be rebuilt using the templates if a template file is saved.
Reproduction Example ๐พ
- Initialise the HtmlWebpackPlugin
new HtmlWebpackPlugin({
filename: "./index.html",
template: resolve(__dirname, "../static/index.html"),
inject: "body",
}),
- Insert the template
<!DOCTYPE html>
<html lang="en">
<%= compilation.assets["html/head.html"].source() %>
<body>
- Save the
head.html
file. - The fill will not be rebuilt (sometimes it rebuilds for me but only once)
- My full source code is available here https://github.com/Miodec/monkeytype
I also tried setting it up on codesandbox but couldn't get the other HTML file to show up in compilation.assets
https://codesandbox.io/s/html-webpack-plugin-5-x-alpha-forked-772ck7?file=/src/index.html
Hopefully this is okay, if not let me know.
Environment ๐ฅ
node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
Node.js v16.13.2
darwin 21.4.0
npm --version
8.1.2
npm ls webpack
monkeytype@1.5.6 /Users/jackbartnik/Documents/Code/monkeytype
โโโ (empty)
npm ls html-webpack-plugin
monkeytype@1.5.6 /Users/jackbartnik/Documents/Code/monkeytype
โโโ (empty)