mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-21 20:08:41 -05:00
fix: object returned from api.configureWebpack should be merged
This commit is contained in:
@@ -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([{
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user