diff --git a/CHANGELOG.md b/CHANGELOG.md index 096dc2593773..1b28ccfe6386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Don't mutate custom color palette when overriding per-plugin colors ([#6546](https://github.com/tailwindlabs/tailwindcss/pull/6546)) ## [3.0.6] - 2021-12-16 diff --git a/src/util/resolveConfig.js b/src/util/resolveConfig.js index 3703f56fc46e..15b876e88ff0 100644 --- a/src/util/resolveConfig.js +++ b/src/util/resolveConfig.js @@ -6,6 +6,8 @@ import colors from '../public/colors' import { defaults } from './defaults' import { toPath } from './toPath' import { normalizeConfig } from './normalizeConfig' +import isPlainObject from './isPlainObject' +import { cloneDeep } from './cloneDeep' function isFunction(input) { return typeof input === 'function' @@ -144,7 +146,15 @@ function resolveFunctionKeys(object) { val = isFunction(val) ? val(resolvePath, configUtils) : val } - return val === undefined ? defaultValue : val + if (val === undefined) { + return defaultValue + } + + if (isPlainObject(val)) { + return cloneDeep(val) + } + + return val } resolvePath.theme = resolvePath diff --git a/tests/basic-usage.test.js b/tests/basic-usage.test.js index 3bb5bf3741c8..2058a92cbe6c 100644 --- a/tests/basic-usage.test.js +++ b/tests/basic-usage.test.js @@ -57,3 +57,55 @@ test('all plugins are executed that match a candidate', () => { `) }) }) + +test('per-plugin colors with the same key can differ when using a custom colors object', () => { + let config = { + content: [ + { + raw: html` +