"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.configCopyThirdpartyFile = configCopyThirdpartyFile;

var _path = _interopRequireDefault(require("path"));

var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));

var _fs = require("fs");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function configCopyThirdpartyFile(options) {
  const {
    context
  } = options;
  const {
    tpFolder
  } = options.app;

  const tpFolderActualPath = tpFolder && _path.default.join(process.cwd(), context, tpFolder);

  if (!tpFolder || !(0, _fs.existsSync)(tpFolderActualPath)) {
    // console.log(tpFolderActualPath, 'not exist', tpFolder);
    return null;
  }

  return new _copyWebpackPlugin.default({
    patterns: [{
      from: `${tpFolderActualPath}/`,
      to: `./${tpFolder}/`,
      toType: 'dir'
    }]
  });
}