From 3edab4de8848b9641ca7b02f014a44966f8ca855 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Mon, 4 Jul 2016 11:14:54 +0800 Subject: [PATCH] fix: avoid child compilation listen parent's plugin As Html-webpack-plugin runs a child compiler, which initiated with part of parent compiler's plugins by webpack. If we listen on `compilation`, handlers in `webpack-split-by-path` will be copy to the child compilation instance, which cases some unwanted extraction. So, we just listen to `this-compilation`. See https://github.com/webpack/webpack/blob/webpack-1/lib/Compiler.js#L327-L328 and https://github.com/webpack/webpack/blob/webpack-1/lib/Compiler.js#L363-L364 --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index eebdd1f..d4290ed 100644 --- a/index.js +++ b/index.js @@ -71,7 +71,7 @@ SplitByPathPlugin.prototype.apply = function (compiler) { var ignoreChunks = this.ignoreChunks; var manifestName = this.manifest; - compiler.plugin('compilation', function (compilation) { + compiler.plugin('this-compilation', function (compilation) { var extraChunks = {}; // Find the chunk which was already created by this bucket. @@ -81,7 +81,6 @@ SplitByPathPlugin.prototype.apply = function (compiler) { } compilation.plugin('optimize-chunks', function (chunks) { - if(this.name) return var addChunk = this.addChunk.bind(this);