Skip to content

Commit b276085

Browse files
authored
Include default config by default in presets (#2660)
1 parent de7da05 commit b276085

File tree

2 files changed

+65
-12
lines changed

2 files changed

+65
-12
lines changed

__tests__/customConfig.test.js

+62-9
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,17 @@ test('the default config can be overridden using the presets key', () => {
218218
{
219219
theme: {
220220
extend: {
221-
colors: {
222-
black: 'black',
221+
minHeight: {
222+
24: '24px',
223223
},
224-
backgroundColor: (theme) => theme('colors'),
225224
},
226225
},
227-
corePlugins: ['backgroundColor'],
226+
corePlugins: ['minHeight'],
227+
variants: { minHeight: [] },
228228
},
229229
],
230230
theme: {
231-
extend: { colors: { white: 'white' } },
231+
extend: { minHeight: { 48: '48px' } },
232232
},
233233
}),
234234
])
@@ -240,11 +240,62 @@ test('the default config can be overridden using the presets key', () => {
240240
)
241241
.then((result) => {
242242
const expected = `
243-
.bg-black {
244-
background-color: black;
243+
.min-h-0 {
244+
min-height: 0;
245245
}
246-
.bg-white {
247-
background-color: white;
246+
.min-h-24 {
247+
min-height: 24px;
248+
}
249+
.min-h-48 {
250+
min-height: 48px;
251+
}
252+
.min-h-full {
253+
min-height: 100%;
254+
}
255+
.min-h-screen {
256+
min-height: 100vh;
257+
}
258+
`
259+
260+
expect(result.css).toMatchCss(expected)
261+
})
262+
})
263+
264+
test('the default config can be removed by using an empty presets key in a preset', () => {
265+
return postcss([
266+
tailwind({
267+
presets: [
268+
{
269+
presets: [],
270+
theme: {
271+
extend: {
272+
minHeight: {
273+
24: '24px',
274+
},
275+
},
276+
},
277+
corePlugins: ['minHeight'],
278+
variants: { minHeight: [] },
279+
},
280+
],
281+
theme: {
282+
extend: { minHeight: { 48: '48px' } },
283+
},
284+
}),
285+
])
286+
.process(
287+
`
288+
@tailwind utilities
289+
`,
290+
{ from: undefined }
291+
)
292+
.then((result) => {
293+
const expected = `
294+
.min-h-24 {
295+
min-height: 24px;
296+
}
297+
.min-h-48 {
298+
min-height: 48px;
248299
}
249300
`
250301

@@ -257,13 +308,15 @@ test('presets can have their own presets', () => {
257308
tailwind({
258309
presets: [
259310
{
311+
presets: [],
260312
theme: {
261313
colors: { red: '#dd0000' },
262314
},
263315
},
264316
{
265317
presets: [
266318
{
319+
presets: [],
267320
theme: {
268321
colors: {
269322
transparent: 'transparent',

src/util/getAllConfigs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import defaultConfig from '../../stubs/defaultConfig.stub.js'
22
import { flagEnabled } from '../featureFlags'
33
import { flatMap, get } from 'lodash'
44

5-
export default function getAllConfigs(config, defaultPresets = [defaultConfig]) {
6-
const configs = flatMap([...get(config, 'presets', defaultPresets)].reverse(), (preset) => {
7-
return getAllConfigs(preset, [])
5+
export default function getAllConfigs(config) {
6+
const configs = flatMap([...get(config, 'presets', [defaultConfig])].reverse(), (preset) => {
7+
return getAllConfigs(preset)
88
})
99

1010
const features = {

0 commit comments

Comments
 (0)