Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev server is not rebuilding the HTML file when using templating #1745

Open
Miodec opened this issue Apr 20, 2022 · 0 comments
Open

Dev server is not rebuilding the HTML file when using templating #1745

Miodec opened this issue Apr 20, 2022 · 0 comments

Comments

@Miodec
Copy link

Miodec commented Apr 20, 2022

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>

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

[email protected] /Users/jackbartnik/Documents/Code/monkeytype
└── (empty)

npm ls html-webpack-plugin

[email protected] /Users/jackbartnik/Documents/Code/monkeytype
└── (empty)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant