fix: object returned from api.configureWebpack should be merged

This commit is contained in:
Evan You
2018-02-05 19:57:57 -05:00
parent 71e1d6f6fe
commit 920d8fa539
2 changed files with 20 additions and 1 deletions
@@ -140,6 +140,24 @@ test('api: configureWebpack', () => {
expect(config.output.path).toBe('test-dist-2')
})
test('api: configureWebpack returning object', () => {
const service = createMockService([{
id: 'test',
apply: api => {
api.configureWebpack(config => {
return {
output: {
path: 'test-dist-3'
}
}
})
}
}])
const config = service.resolveWebpackConfig()
expect(config.output.path).toBe('test-dist-3')
})
test('api: configureDevServer', () => {
const cb = () => {}
const service = createMockService([{
+2 -1
View File
@@ -143,7 +143,8 @@ module.exports = class Service {
this.webpackRawConfigFns.forEach(fn => {
if (typeof fn === 'function') {
// function with optional return value
config = fn(config) || config
const res = fn(config)
if (res) config = merge(config, res)
} else if (fn) {
// merge literal values
config = merge(config, fn)