log-webpack-plugin

a note for study webpack plugin

MIT License

Stars
1

log-webpack-plugin

webpack plugin js constructor options

apply webpack new MyPlugin compiler

hooks

compiler.hooks.compile.tapAsync("LogWebpackPlugin", function(
  compilation,
  callback
) {
  // compilation.chunks 
  compilation.chunks.forEach(function(chunk) {
    // chunk 
    //  chunk.forEachModule 
    for (const module of chunk.modulesIterable) {
      // module 
      // module.dependencies 
      module.dependencies.forEach(function(filepath) {
        console.log(filepath);
      });
    }

    // Webpack  Chunk  Chunk 
    //  Chunk  CSS  ExtractTextPlugin 
    //  Chunk  .js  .css 
    chunk.files.forEach(function(filename) {
      // compilation.assets 
      //  source() 
      let source = compilation.assets[filename].source();
    });
  });

  //  callback  Webpack 
  //  callbackWebpack 
  callback();
});