UNPKG

1 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = mergeCustomConfig;
7
8var _fs = require('fs');
9
10function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
11
12/**
13 * Merge custom config from `webpack.config.js`.
14 * @param webpackConfig {Object}
15 * @param customConfigPath {String}
16 */
17function mergeCustomConfig(webpackConfig, customConfigPath) {
18 if (!(0, _fs.existsSync)(customConfigPath)) {
19 return webpackConfig;
20 }
21
22 var customConfig = require(customConfigPath);
23 /* eslint prefer-rest-params:0 */
24 if (typeof customConfig === 'function') {
25 return customConfig.apply(undefined, [webpackConfig].concat(_toConsumableArray([].concat(Array.prototype.slice.call(arguments)).slice(2))));
26 }
27
28 throw new Error('Return of ' + customConfigPath + ' must be a function.');
29}
30module.exports = exports['default'];
\No newline at end of file