webpack recompile but nothing changed

17 Views Asked by At

how to make webpack recompile on dev mode with cache on?

trying to write a plugin based on HtmlWebpackPlugin to change the output of html.

dev mode with cache on, if index.html is not changed, how to make webpack recompile

class MyPlugin {
  apply(compiler) {
    compiler.hooks.compilation.tap("MyPlugin", (compilation) => {
      HtmlWebpackPlugin.getCompilationHooks(compilation).beforeEmit.tapAsync(
        "MyPlugin",
        (data, cb) => {
          axios
            .get("xxxxx.com/get_data")
            .then(function (response) {
              data.html += response.data;
              cb(null, data);
            });
        },
      );
    });

    let value

    setInterval(() => {
      axios
      .get("xxxxx.com/get_data")
      .then(function (response) {
        if (response.data !== value) {
          // trigger recompile
        }
        value = response.data
      });
    }, 60000)
  }
}

dev mode with cache on, compiler.compile() won't regenerate html

0

There are 0 best solutions below