diff --git a/index.js b/index.js index fae1266..a929f64 100644 --- a/index.js +++ b/index.js @@ -41,8 +41,8 @@ WebpackCopyOnPlugin.prototype.apply = function(compiler) { }; compiler.plugin(eventHook, function(stats) { - const statsJson = stats.toJson(); - const chunks = statsJson.chunks; + const statsJson = stats.toJson ? stats.toJson() : {}; + const chunks = statsJson.chunks ? statsJson.chunks : []; chunks.forEach(function(chunk) { const chunkName = chunk.names[0]; let mapping = mappings[chunkName];