UNPKG

webpack-config

Version:

Helps to load, extend and merge webpack configs

40 lines (32 loc) 1.1 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _lodash = require('lodash'); var _ConfigCommand = require('./ConfigCommand'); var _ConfigCommand2 = _interopRequireDefault(_ConfigCommand); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @class * @extends {ConfigCommand} */ class ConfigMergeCommand extends _ConfigCommand2.default { /** * @override */ execute(config, options) { const value = this.optionsResolver.resolve(config, options); (0, _lodash.mergeWith)(config, value, (x, y) => { // eslint-disable-line consistent-return if (Array.isArray(x) && Array.isArray(y)) { return [...x, ...y]; } else if (Array.isArray(x) && (0, _lodash.isObject)(y)) { return [...x, y]; } else if ((0, _lodash.isObject)(x) && Array.isArray(y)) { return [x, ...y]; } }); } } exports.default = ConfigMergeCommand; //# sourceMappingURL=ConfigMergeCommand.js.map