Skip to content

Commit

Permalink
fix: avoid child compilation listen parent's plugin
Browse files Browse the repository at this point in the history
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
  • Loading branch information
e-cloud committed Jul 4, 2016
1 parent 4d02cc0 commit 3edab4d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);

Expand Down

0 comments on commit 3edab4d

Please sign in to comment.