piral-cli-webpack5
Version:
Provides debug and build capabilities for pilets and Piral instances using Webpack v5.
37 lines • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extendConfig = extendConfig;
const fs_1 = require("fs");
function extendConfig([webPackConfig, enhancer], otherConfigPath, overrides = {}) {
const original = webPackConfig;
if ((0, fs_1.existsSync)(otherConfigPath)) {
try {
const otherConfig = require(otherConfigPath);
if (typeof otherConfig === 'function') {
webPackConfig = otherConfig(webPackConfig);
}
else if (typeof otherConfig === 'object') {
webPackConfig = {
...webPackConfig,
...otherConfig,
};
}
else {
console.warn(`Did not recognize the export from "${otherConfigPath}". Skipping.`);
}
}
catch (ex) {
console.error(`Error while using the config from "${otherConfigPath}": ${ex}`);
}
}
['entry', 'output', 'optimization'].forEach((s) => {
if (original[s] !== webPackConfig[s]) {
console.warn(`You've overwritten the "${s}" section of the Webpack config. Make sure you know what you are doing.`);
}
});
return enhancer({
...webPackConfig,
...overrides,
});
}
//# sourceMappingURL=helpers.js.map