diff --git a/README.md b/README.md index 1332bd9..234a0e0 100644 --- a/README.md +++ b/README.md @@ -408,6 +408,9 @@ config.entryPoints config.entryPoints .get(name) .clear() + +// Set entry to be a single value instead of a ChainedMap +config.set('singleEntry', entryPath) ``` #### Config output: shorthand methods diff --git a/src/Config.js b/src/Config.js index 4452e04..0d7fa77 100644 --- a/src/Config.js +++ b/src/Config.js @@ -37,6 +37,7 @@ module.exports = class extends ChainedMap { 'recordsInputPath', 'recordsPath', 'recordsOutputPath', + 'singleEntry', 'stats', 'target', 'watch', @@ -117,6 +118,14 @@ module.exports = class extends ChainedMap { toConfig() { const entryPoints = this.entryPoints.entries() || {}; + const entry = this.has('singleEntry') + ? this.get('singleEntry') + : Object.keys(entryPoints).reduce( + (acc, key) => + Object.assign(acc, { [key]: entryPoints[key].values() }), + {}, + ); + return this.clean( Object.assign(this.entries() || {}, { node: this.node.entries(), @@ -128,11 +137,8 @@ module.exports = class extends ChainedMap { optimization: this.optimization.toConfig(), plugins: this.plugins.values().map(plugin => plugin.toConfig()), performance: this.performance.entries(), - entry: Object.keys(entryPoints).reduce( - (acc, key) => - Object.assign(acc, { [key]: entryPoints[key].values() }), - {}, - ), + entry, + singleEntry: undefined, }), ); } diff --git a/test/Config.js b/test/Config.js index 1b9be06..d3e7c2e 100644 --- a/test/Config.js +++ b/test/Config.js @@ -61,6 +61,16 @@ test('entry', t => { ]); }); +test('single string entry', t => { + const config = new Config(); + + config.set('singleEntry', 'src/index.js'); + + t.deepEqual(config.toConfig(), { + entry: 'src/index.js', + }); +}); + test('plugin empty', t => { const config = new Config(); const instance = config