Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Adding config.set('singleEntry'). Resolves #230. #239

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adding config.set('singleEntry'). Resolves #230.
jolyndenning committed Jan 28, 2020
commit 0d002b1e5d2cc4dabbe72c453a8ae4c77787e7d2
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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', 'src/index.js')
```

#### Config output: shorthand methods
16 changes: 11 additions & 5 deletions src/Config.js
Original file line number Diff line number Diff line change
@@ -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,
}),
);
}
10 changes: 10 additions & 0 deletions test/Config.js
Original file line number Diff line number Diff line change
@@ -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