diff --git a/lib/config.js b/lib/config.js index 08c8825..dc5b5d9 100644 --- a/lib/config.js +++ b/lib/config.js @@ -26,7 +26,7 @@ module.exports = class Config { throw new Error('[spike constructor] option "root" is required') } // merges API options into app.js options - let allOpts = Object.assign(this.parseAppJs(opts), opts) + let allOpts = merge(this.parseAppJs(opts), opts) this.transformSpikeOptionsToWebpack(this.validateOpts(allOpts)) this.project = project } diff --git a/test/app_config.js b/test/app_config.js index 91bb84c..b108a29 100644 --- a/test/app_config.js +++ b/test/app_config.js @@ -13,6 +13,13 @@ test('API config overrides app.js config', (t) => { }) }) +test('API config merges properly with app.js config', (t) => { + return compileFixture(t, 'app_config', { testing: { bar: 'double override' } }).then(({res}) => { + t.truthy(res.stats.compilation.options.testing.baz === 'override') + t.truthy(res.stats.compilation.options.testing.bar === 'double override') + }) +}) + test('throws error for invalid app.js syntax', (t) => { return t.throws(() => compileFixture(t, 'app_config_error'), /Error: wow/) }) diff --git a/test/fixtures/app_config/app.js b/test/fixtures/app_config/app.js index 71d4551..4ce9b66 100644 --- a/test/fixtures/app_config/app.js +++ b/test/fixtures/app_config/app.js @@ -1,5 +1,7 @@ module.exports = { testing: { - foo: 'override' + foo: 'override', + bar: 'override', + baz: 'override' } }