var fse = require("fs-extra");

function WebpackCopyAfterBuildPlugin(mappings) {
  this._mappings = mappings || {};
}

WebpackCopyAfterBuildPlugin.prototype.apply = function(compiler) {
  var mappings = this._mappings;

  compiler.plugin("done", function(stats) {
    var statsJson = stats.toJson();
    var chunks = statsJson.chunks;

    chunks.forEach(function(chunk) {
      var chunkName = chunk.names[0];
      var mapping = mappings[chunkName];

      if (mapping) {
        var devServer = compiler.options.devServer;
        var outputPath;

        if (devServer && devServer.contentBase) {
          outputPath = devServer.contentBase;
        } else {
          outputPath = compiler.options.output.path;
        }

        var chunkFilename = chunk.files[0];
        var from = outputPath + "/" + chunkFilename;
        var to = outputPath + "/" + mapping;

        fse.copySync(from, to);
      }
    });
  });
};

module.exports = WebpackCopyAfterBuildPlugin;

var fse = require("fs-extra");

function WebpackCopyAfterBuildPlugin(mappings) {
  this._mappings = mappings || {};
}

WebpackCopyAfterBuildPlugin.prototype.apply = function(compiler) {
  var mappings = this._mappings;

  compiler.plugin("done", function(stats) {
    var statsJson = stats.toJson();
    var chunks = statsJson.chunks;

    chunks.forEach(function(chunk) {
      var bundleName = chunk.names[0];
      var mapping = mappings[bundleName];

      if (mapping) {
        var devServer = compiler.options.devServer;
        var outputPath;

        if (devServer && devServer.contentBase) {
          outputPath = devServer.contentBase;
        } else {
          outputPath = compiler.options.output.path;
        }

        var webpackContext = compiler.options.context;
        var chunkHashFileName = chunk.files[0];
        var from = webpackContext + "/" + outputPath + "/" + chunkHashFileName;
        var to = webpackContext + "/" + outputPath + "/" + mapping;

        fse.copySync(from, to);
      }
    });
  });
};

module.exports = WebpackCopyAfterBuildPlugin;

--- 
+++ 
@@ -12,8 +12,8 @@
     var chunks = statsJson.chunks;
 
     chunks.forEach(function(chunk) {
-      var bundleName = chunk.names[0];
-      var mapping = mappings[bundleName];
+      var chunkName = chunk.names[0];
+      var mapping = mappings[chunkName];
 
       if (mapping) {
         var devServer = compiler.options.devServer;
@@ -25,10 +25,9 @@
           outputPath = compiler.options.output.path;
         }
 
-        var webpackContext = compiler.options.context;
-        var chunkHashFileName = chunk.files[0];
-        var from = webpackContext + "/" + outputPath + "/" + chunkHashFileName;
-        var to = webpackContext + "/" + outputPath + "/" + mapping;
+        var chunkFilename = chunk.files[0];
+        var from = outputPath + "/" + chunkFilename;
+        var to = outputPath + "/" + mapping;
 
         fse.copySync(from, to);
       }
Fix copy with absolute paths
