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

Html hot update #1480

Closed
vin-ni opened this issue Jul 11, 2020 · 11 comments
Closed

Html hot update #1480

vin-ni opened this issue Jul 11, 2020 · 11 comments

Comments

@vin-ni
Copy link

vin-ni commented Jul 11, 2020

Hello,
is it possible to get the html updated on save?

Thanks!

@jantimon
Copy link
Owner

Unfortunately that’s not possible because we don’t know which changes to the html are caused by javascript...

But I am open to ideas to solve this

@vin-ni
Copy link
Author

vin-ni commented Jul 12, 2020

Sorry,
i meant the index.html

When I update it, it doesnt reload the page.

@jantimon
Copy link
Owner

Reloading should be possible however we would need help from the webpack core team to use the webpack-dev-server socket connection

@bebraw
Copy link

bebraw commented Jul 22, 2020

@vin-ni To "solve" this issue, I developed webpack-add-dependency-plugin. It allows you to make webpack aware of these kind of template files that are indirect dependencies to it and I've used it myself to solve a similar use case.

@jantimon
Copy link
Owner

jantimon commented Jul 22, 2020

Wow @bebraw that's cool - do you think we should use it directly with the html webpack plugin?

e.g.

apply(compiler) {
  const webpackAddDependencyPlugin = new WebpackAddDependencyPlugin({ path: this.options.template });
  webpackAddDependencyPlugin.apply(compiler);

Will it trigger a reload?

Webpack already tracks all files from the html-webpack-plugin as dependencies.

@bebraw
Copy link

bebraw commented Jul 22, 2020 via email

@bebraw
Copy link

bebraw commented Oct 16, 2020

@jantimon Did you find a solution for this in webpack 5?

@jantimon
Copy link
Owner

I checked the webpack-add-dependency-plugin but unfortunately it won’t help here as all files are already added by the html-webpack-plugin

An auto reload feature would need to be exposed by the webpack-dev-server however there is none :(

@bebraw
Copy link

bebraw commented Oct 16, 2020

I checked the webpack-add-dependency-plugin but unfortunately it won’t help here as all files are already added by the html-webpack-plugin

Ok, I see.

An auto reload feature would need to be exposed by the webpack-dev-server however there is none :(

Can you open an issue at webpack-plugin-serve describing what you would need? I am not sure if we can do it there but it's worth discussing at least.

@peteluffman
Copy link

Not sure if it helps anyone, but I got reloading working with webpack 5 by adding injectClient: true to my devServer config.

@alwxkxk
Copy link

alwxkxk commented Dec 5, 2021

With webpack 5,this setting is work for me:

  devServer: {
    hot:true,
    open:true,
    watchFiles: ['src/**/*']
  },

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

5 participants