jantimon/html-webpack-plugin

How can i update plugin instance on runtime?

NiceOkay opened this issue · 4 comments

Prerequisites

  • html-webpack-plugin`

Description

I run webpack on watch mode and my templates will can dynamic removed or added:

  1. how can i create new instance for added templates without restart process and hooks.initialize (because hooks.iitialize emitted before hooks.watchRun)
  2. how can i disabled existing instance for removed template (entrypoint), so that are no errors in compilation (Error: Child compilation failed: Module not found:)

Unfortunately this is not possible right now.
The easiest approach would probably be to us a client side router..

thanks for the answer, I don't even know what i can think of :)

Point 1:
when added new template i create new instance and call hooks.initialize

const plugin = new HtmlWebpackPlugin(...options);
plugin.apply(compiler);
compiler.options.plugins.push(plugin);
compiler.hooks.initialize.call();

its work

stale commented

This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days.