没有消息的 webpack 警告

webpack warning without message

首先 webpack compiles with warnings, but the warning messages are blank 的答案无效。

我在使用 pwa 模式时使用 quasar 1v 项目进行增量构建时得到以下信息。

WARNING Compiled with 1 warnings

warning

我尝试像这样将 'verbose'{ warnings: true } 添加到 webpack 配置中

{
  build: {
    extendWebpack(cfg) {
      cfg.stats = 'verbose';
      // or
      cfg.stats = { warnings: true };
    }
  }
}

quasar inspect -p stats 预期输出,但没有变化。

如何调查此警告?

ps 警告似乎也阻止了热重载的工作(我必须手动刷新每个更改)

插件挂钩就是答案。

就我而言,警告是:

InjectManifest has been called `multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may be inaccurate! Please see https://github.com/GoogleChrome/workbox/issues/1790 for more information.

作为字符串,没有对象,因此无法正确显示。我通过

找到了它

my-plugin.js

class MyPlugin {
  apply(compiler) {
    compiler.hooks.done.tap(
      "MyPlugin",
      ({ compilation } => {
        console.log("done");
        console.log(`warnings ${compilation.warnings.length}`);
        compilation.warnings.forEach((warning, index) => {
          console.log(`warning ${typeof warning}`);
          console.log(warning);
        });
      })
    );
  }
}

quasar.conf.js

{
  build: {
    extendWebpack(cfg) {
      cfg.plugins = cfg.plugins || [];
      cfg.plugins.push(new MyPlugin());
    }
  }
}

导致

WARNING Compiled with 1 warnings

warning

done
warnings 1
warning string
InjectManifest has been called `multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may be inaccurate! Please see https://github.com/GoogleChrome/workbox/issues/1790 for more information.