Webpack 自定义网页包插件:哪个钩子用于访问转换后的代码

Webpack 自定义网页包插件:哪个钩子用于访问转换后的代码,webpack,webpack-plugin,webpack-loader,Webpack,Webpack Plugin,Webpack Loader,我试图在网页包插件中的某个加载程序完成其工作后,让加载程序转换文件内容。这通常是另一个加载程序的理想选择,但我还需要访问在翻译过程结束时调用的钩子(因此选择编写插件)。我是否需要一个不同于emit的钩子,以及允许访问转换文件内容的参数的属性是什么 compiler.plugin('done', () => { // some finalization code }); compiler.plugin('emit', (compilation, cal

我试图在网页包插件中的某个加载程序完成其工作后,让加载程序转换文件内容。这通常是另一个加载程序的理想选择,但我还需要访问在翻译过程结束时调用的钩子(因此选择编写插件)。我是否需要一个不同于
emit
的钩子,以及允许访问转换文件内容的参数的属性是什么

    compiler.plugin('done', () => {
       // some finalization code
    });

    compiler.plugin('emit', (compilation, callback) => {
      compilation.chunks.forEach((chunk) => {
        chunk.forEachModule((module) => {
          let filename = module.resource;
          // I could load filename from the filesystem, but I need the content
          // of the file that's gone through the loader pipeline (ideally
          // after a certain loader, but I think at the end of the
          // pipeline would also be fine).
        })
     });

我正在使用webpack 3,但我应该能够从webpack 4解决方案中进行翻译。

我最终编写了一个插件,在解析后在
上动态注入加载程序(您必须手动检查要注入加载程序的“模块”及其位置)并为
done
事件安装一个钩子,将所有内容写入磁盘