Templates

MainTemplate

startup(source, module, hash)

compilation.mainTemplate.plugin('startup', function(source, module, hash) {
  if (!module.chunks.length && source.indexOf('__ReactStyle__') === -1) {
    var originName = module.origins && module.origins.length ? module.origins[0].name : 'main';
    return [
      'if (typeof window !== "undefined") {',
        '  window.__ReactStyle__ = ' + JSON.stringify(classNames[originName]) + ';',
      '}'
    ].join('\n') + source;
  }
  return source;
});

ModuleTemplate

Document the ModuleTemplate...

ChunkTemplate

Document the ChunkTemplate...

FunctionModuleTemplate

Document the FunctionModuleTemplate...

HotUpdateChunkTemplate

Document the HotUpdateChunkTemplate...

原文:https://webpack.js.org/api/template/