MCPcopy Index your code
hub / github.com/developit/optimize-plugin / apply

Method apply

src/index.js:467–496  ·  view source on GitHub ↗
(compiler)

Source from the content-addressed store, hash-verified

465 }
466
467 apply (compiler) {
468 this.workerPool = new WorkerPool({
469 workerPath: require.resolve('./worker'),
470 concurrency: this.options.concurrency
471 });
472
473 compiler.hooks.compilation.tap(NAME, compilation => {
474 this.updateChunkHash(compilation);
475
476 if (this.isWebpack5()) {
477 compilation.hooks.processAssets.tapPromise({
478 name: NAME,
479 stage: this.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
480 }, (assets) => {
481 const chunkFiles = Object.keys(assets);
482
483 return this.optimize(compiler, compilation, chunkFiles);
484 });
485 } else {
486 compilation.hooks.optimizeChunkAssets.tapPromise(NAME, (chunks) => {
487 const chunkFiles = Array.from(chunks).reduce(
488 (acc, chunk) => acc.concat(Array.from(chunk.files || [])),
489 []
490 );
491
492 return this.optimize(compiler, compilation, chunkFiles);
493 });
494 }
495 });
496 }
497}

Callers

nothing calls this directly

Calls 3

updateChunkHashMethod · 0.95
isWebpack5Method · 0.95
optimizeMethod · 0.95

Tested by

no test coverage detected