diff --git a/CHANGELOG.md b/CHANGELOG.md index 7689ced86d8e..2af53df9947e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nothing yet! +## [1.9.6] + +### Changed + +- The `presets` feature had unexpected behavior where a preset config without its own `presets` key would not extend the default config. ([#2662](https://github.com/tailwindlabs/tailwindcss/pull/2662)) + + If you were depending on this unexpected behavior, just add `presets: []` to your own preset to exclude the default configuration. + ## [1.9.5] ### Fixed @@ -1000,8 +1008,9 @@ No release notes - Everything! -[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.5...HEAD -[1.9.5]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.3...v1.9.5 +[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.6...HEAD +[1.9.6]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.5...v1.9.6 +[1.9.5]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.4...v1.9.5 [1.9.4]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.3...v1.9.4 [1.9.3]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.2...v1.9.3 [1.9.2]: https://github.com/tailwindlabs/tailwindcss/compare/v1.9.1...v1.9.2 diff --git a/__tests__/customConfig.test.js b/__tests__/customConfig.test.js index ae00c0ba61e2..fbbcab59a46c 100644 --- a/__tests__/customConfig.test.js +++ b/__tests__/customConfig.test.js @@ -218,17 +218,17 @@ test('the default config can be overridden using the presets key', () => { { theme: { extend: { - colors: { - black: 'black', + minHeight: { + 24: '24px', }, - backgroundColor: theme => theme('colors'), }, }, - corePlugins: ['backgroundColor'], + corePlugins: ['minHeight'], + variants: { minHeight: [] }, }, ], theme: { - extend: { colors: { white: 'white' } }, + extend: { minHeight: { 48: '48px' } }, }, }), ]) @@ -240,11 +240,62 @@ test('the default config can be overridden using the presets key', () => { ) .then(result => { const expected = ` - .bg-black { - background-color: black; + .min-h-0 { + min-height: 0; } - .bg-white { - background-color: white; + .min-h-24 { + min-height: 24px; + } + .min-h-48 { + min-height: 48px; + } + .min-h-full { + min-height: 100%; + } + .min-h-screen { + min-height: 100vh; + } + ` + + expect(result.css).toMatchCss(expected) + }) +}) + +test('the default config can be removed by using an empty presets key in a preset', () => { + return postcss([ + tailwind({ + presets: [ + { + presets: [], + theme: { + extend: { + minHeight: { + 24: '24px', + }, + }, + }, + corePlugins: ['minHeight'], + variants: { minHeight: [] }, + }, + ], + theme: { + extend: { minHeight: { 48: '48px' } }, + }, + }), + ]) + .process( + ` + @tailwind utilities + `, + { from: undefined } + ) + .then(result => { + const expected = ` + .min-h-24 { + min-height: 24px; + } + .min-h-48 { + min-height: 48px; } ` @@ -257,6 +308,7 @@ test('presets can have their own presets', () => { tailwind({ presets: [ { + presets: [], theme: { colors: { red: '#dd0000' }, }, @@ -264,6 +316,7 @@ test('presets can have their own presets', () => { { presets: [ { + presets: [], theme: { colors: { transparent: 'transparent', diff --git a/__tests__/purgeUnusedStyles.test.js b/__tests__/purgeUnusedStyles.test.js index 093efbb5c56d..f83444ca192d 100644 --- a/__tests__/purgeUnusedStyles.test.js +++ b/__tests__/purgeUnusedStyles.test.js @@ -58,6 +58,8 @@ const config = { }, } +delete config.presets + function assertPurged(result) { expect(result.css).not.toContain('.bg-red-600') expect(result.css).not.toContain('.w-1\\/3') diff --git a/package.json b/package.json index e23554a05e54..d1ae50b6fb68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tailwindcss", - "version": "1.9.5", + "version": "1.9.6", "description": "A utility-first CSS framework for rapidly building custom user interfaces.", "license": "MIT", "main": "lib/index.js", diff --git a/src/util/getAllConfigs.js b/src/util/getAllConfigs.js index ef67e06ce8c8..e576b535932b 100644 --- a/src/util/getAllConfigs.js +++ b/src/util/getAllConfigs.js @@ -9,9 +9,9 @@ import standardFontWeights from '../flagged/standardFontWeights' import additionalBreakpoint from '../flagged/additionalBreakpoint' import { flatMap, get } from 'lodash' -export default function getAllConfigs(config, defaultPresets = [defaultConfig]) { - const configs = flatMap([...get(config, 'presets', defaultPresets)].reverse(), preset => { - return getAllConfigs(preset, []) +export default function getAllConfigs(config) { + const configs = flatMap([...get(config, 'presets', [defaultConfig])].reverse(), preset => { + return getAllConfigs(preset) }) const features = { diff --git a/stubs/defaultConfig.stub.js b/stubs/defaultConfig.stub.js index 4104ec901422..a739f13431a8 100644 --- a/stubs/defaultConfig.stub.js +++ b/stubs/defaultConfig.stub.js @@ -8,6 +8,7 @@ module.exports = { prefix: '', important: false, separator: ':', + presets: [], theme: { screens: { sm: '640px',