styleguidist/mini-html-webpack-plugin

Changes made to template context don't trigger a reload in webpack dev mode

bebraw opened this issue · 1 comments

In case you modify the template provided by context while running webpack-dev-server, browser won't refresh automatically.

Most likely we'll have to make it "watchable" somehow by webpack to fix this.

This is tricky since we cannot tell where the context content is coming from.

As a workaround, I wrote a small plugin to inject the files to webpack depsgraph:

class AddDependencyPlugin {
  constructor(options = {}) {
    this.options = options;
    this.plugin = this.plugin.bind(this);
  }

  plugin(compilation, callback) {
    const { path } = this.options;

    compilation.fileDependencies.add(path);

    callback();
  }

  apply(compiler) {
    compiler.hooks.emit.tapAsync("AddDependencyPlugin", this.plugin);
  }
}

The idea is to apply that against files within context.

I am closing this issue as we cannot fix it in a good way within mini-html-webpack-plugin.