diff --git a/__tests__/resolveConfig.test.js b/__tests__/resolveConfig.test.js index f1e13a2a4..e75b47b79 100644 --- a/__tests__/resolveConfig.test.js +++ b/__tests__/resolveConfig.test.js @@ -826,3 +826,43 @@ test('theme values in the extend section are lazily evaluated', () => { }, }) }) + +test('the original theme is not mutated', () => { + const userConfig = { + theme: { + extend: { + colors: { + orange: 'orange', + }, + }, + }, + } + + const defaultConfig = { + prefix: '-', + important: false, + separator: ':', + theme: { + colors: { + cyan: 'cyan', + magenta: 'magenta', + yellow: 'yellow', + }, + }, + variants: { + borderColor: ['responsive', 'hover', 'focus'], + }, + } + + resolveConfig([userConfig, defaultConfig]) + + expect(userConfig).toEqual({ + theme: { + extend: { + colors: { + orange: 'orange', + }, + }, + }, + }) +}) diff --git a/src/util/resolveConfig.js b/src/util/resolveConfig.js index 0db03c222..10eefc0ef 100644 --- a/src/util/resolveConfig.js +++ b/src/util/resolveConfig.js @@ -38,7 +38,7 @@ function resolveFunctionKeys(object) { export default function resolveConfig(configs) { return defaults( { - theme: resolveFunctionKeys(mergeExtensions(defaults(...map(configs, 'theme')))), + theme: resolveFunctionKeys(mergeExtensions(defaults({}, ...map(configs, 'theme')))), variants: defaults(...map(configs, 'variants')), }, ...configs