-
Notifications
You must be signed in to change notification settings - Fork 233
allow config entry to be an array or string #107
allow config entry to be an array or string #107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thank you for the PR :-)
I don't suppose you could add a test in here?
https://github.com/neutrinojs/webpack-chain/blob/master/test/Config.js
There are some tests for .merge()
here that might be useful for inspiration:
Lines 67 to 127 in bd644d3
test('merge empty', t => { | |
const resolve = new Resolve(); | |
const obj = { | |
modules: ['src'], | |
extensions: ['.js'], | |
alias: { React: 'src/react' }, | |
}; | |
const instance = resolve.merge(obj); | |
t.is(instance, resolve); | |
t.deepEqual(resolve.toConfig(), obj); | |
}); | |
test('merge with values', t => { | |
const resolve = new Resolve(); | |
resolve.modules | |
.add('src') | |
.end() | |
.extensions.add('.js') | |
.end() | |
.alias.set('React', 'src/react'); | |
resolve.merge({ | |
modules: ['dist'], | |
extensions: ['.jsx'], | |
alias: { ReactDOM: 'src/react-dom' }, | |
}); | |
t.deepEqual(resolve.toConfig(), { | |
modules: ['src', 'dist'], | |
extensions: ['.js', '.jsx'], | |
alias: { React: 'src/react', ReactDOM: 'src/react-dom' }, | |
}); | |
}); | |
test('merge with omit', t => { | |
const resolve = new Resolve(); | |
resolve.modules | |
.add('src') | |
.end() | |
.extensions.add('.js') | |
.end() | |
.alias.set('React', 'src/react'); | |
resolve.merge( | |
{ | |
modules: ['dist'], | |
extensions: ['.jsx'], | |
alias: { ReactDOM: 'src/react-dom' }, | |
}, | |
['alias'] | |
); | |
t.deepEqual(resolve.toConfig(), { | |
modules: ['src', 'dist'], | |
extensions: ['.js', '.jsx'], | |
alias: { React: 'src/react' }, | |
}); | |
}); |
Many thanks :-)
(Or if you'd prefer I can add the tests - let me know :-)) |
a8cd606
to
ce5973f
Compare
Added some tests for merge as indicated. Obviously these test more than just the one line change but agreed they are good to add. Feel free to edit or change the pull request if they don't accommodate the needed tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfect, thank you!
This has been released as v4.12.1. |
Config entry points can be singular or multiple.
In readme, it already that values can an array.
A real-life example might have both polyfills and main index file:
This works when adding through the
.entry.add().add()
interface but does not currently work for merge. The proposed change is one line to automatically make the merge value an array if it is not already.