2013-02-24 09:05:55 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2015-07-13 06:20:09 +08:00
|
|
|
function FlagIncludedChunksPlugin() {}
|
2013-02-24 09:05:55 +08:00
|
|
|
module.exports = FlagIncludedChunksPlugin;
|
|
|
|
|
|
|
|
FlagIncludedChunksPlugin.prototype.apply = function(compiler) {
|
|
|
|
compiler.plugin("compilation", function(compilation) {
|
|
|
|
compilation.plugin("optimize-chunk-ids", function(chunks) {
|
|
|
|
chunks.forEach(function(chunkA) {
|
|
|
|
chunks.forEach(function(chunkB) {
|
2015-07-16 06:19:23 +08:00
|
|
|
if(chunkA === chunkB) return;
|
2013-02-24 09:05:55 +08:00
|
|
|
// is chunkB in chunkA?
|
2015-07-16 06:19:23 +08:00
|
|
|
if(chunkA.modules.length < chunkB.modules.length) return;
|
|
|
|
for(var i = 0; i < chunkB.modules.length; i++) {
|
|
|
|
if(chunkA.modules.indexOf(chunkB.modules[i]) < 0) return;
|
2013-02-24 09:05:55 +08:00
|
|
|
}
|
|
|
|
chunkA.ids.push(chunkB.id);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|