Skip to content

Commit b008d0c

Browse files
committed
Remove 'conservative' purge mode
1 parent 4959a99 commit b008d0c

File tree

3 files changed

+4
-95
lines changed

3 files changed

+4
-95
lines changed

__tests__/purgeUnusedStyles.test.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -389,30 +389,6 @@ test('you can purge just base and component layers (but why)', () => {
389389
)
390390
})
391391

392-
test('does not purge components when mode is conservative', () => {
393-
return inProduction(
394-
suppressConsoleLogs(() => {
395-
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
396-
const input = fs.readFileSync(inputPath, 'utf8')
397-
398-
return postcss([
399-
tailwind({
400-
...config,
401-
purge: {
402-
mode: 'conservative',
403-
content: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
404-
},
405-
}),
406-
])
407-
.process(input, { from: inputPath })
408-
.then((result) => {
409-
expect(result.css).toContain('.container')
410-
assertPurged(result)
411-
})
412-
})
413-
)
414-
})
415-
416392
test('extra purgecss control comments can be added manually', () => {
417393
return inProduction(
418394
suppressConsoleLogs(() => {
@@ -632,52 +608,6 @@ test(
632608
})
633609
)
634610

635-
test('the `conservative` mode can be set explicitly', () => {
636-
return inProduction(
637-
suppressConsoleLogs(() => {
638-
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
639-
const input = fs.readFileSync(inputPath, 'utf8')
640-
641-
return postcss([
642-
tailwind({
643-
...config,
644-
purge: {
645-
mode: 'conservative',
646-
content: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
647-
},
648-
}),
649-
])
650-
.process(input, { from: inputPath })
651-
.then((result) => {
652-
expect(result.css).not.toContain('.bg-red-600')
653-
expect(result.css).not.toContain('.w-1\\/3')
654-
expect(result.css).not.toContain('.flex')
655-
expect(result.css).not.toContain('.font-sans')
656-
expect(result.css).not.toContain('.text-right')
657-
expect(result.css).not.toContain('.px-4')
658-
expect(result.css).not.toContain('.h-full')
659-
660-
expect(result.css).toContain('.bg-red-500')
661-
expect(result.css).toContain('.md\\:bg-blue-300')
662-
expect(result.css).toContain('.w-1\\/2')
663-
expect(result.css).toContain('.block')
664-
expect(result.css).toContain('.md\\:flow-root')
665-
expect(result.css).toContain('.h-screen')
666-
expect(result.css).toContain('.min-h-\\(screen-4\\)')
667-
expect(result.css).toContain('.bg-black\\!')
668-
expect(result.css).toContain('.font-\\%\\#\\$\\@')
669-
expect(result.css).toContain('.w-\\(1\\/2\\+8\\)')
670-
expect(result.css).toContain('.inline-grid')
671-
expect(result.css).toContain('.grid-cols-3')
672-
expect(result.css).toContain('.px-1\\.5')
673-
expect(result.css).toContain('.col-span-2')
674-
expect(result.css).toContain('.col-span-1')
675-
expect(result.css).toContain('.text-center')
676-
})
677-
})
678-
)
679-
})
680-
681611
test('element selectors are preserved by default', () => {
682612
return inProduction(
683613
suppressConsoleLogs(() => {

src/featureFlags.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import chalk from 'chalk'
33
import log from './util/log'
44

55
const featureFlags = {
6-
future: [
7-
'purgeLayersByDefault',
8-
'defaultLineHeights',
9-
'standardFontWeights',
10-
'moveTruncateToTextOverflow',
11-
],
6+
future: ['defaultLineHeights', 'standardFontWeights', 'moveTruncateToTextOverflow'],
127
experimental: [
138
'uniformColorPalette',
149
'extendedSpacingScale',

src/lib/purgeUnusedStyles.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,17 @@ export default function purgeUnusedUtilities(config, configChanged) {
4949

5050
return postcss([
5151
function (css) {
52-
const mode = _.get(
53-
config,
54-
'purge.mode',
55-
flagEnabled(config, 'purgeLayersByDefault') ? 'layers' : 'conservative'
56-
)
52+
const mode = _.get(config, 'purge.mode', 'layers')
5753

58-
if (!['all', 'layers', 'conservative'].includes(mode)) {
54+
if (!['all', 'layers'].includes(mode)) {
5955
throw new Error('Purge `mode` must be one of `layers` or `all`.')
6056
}
6157

6258
if (mode === 'all') {
6359
return
6460
}
6561

66-
if (mode === 'conservative') {
67-
if (configChanged) {
68-
log.warn([
69-
'The `conservative` purge mode will be removed in Tailwind 2.0.',
70-
'Please switch to the new `layers` mode instead.',
71-
])
72-
}
73-
}
74-
75-
const layers =
76-
mode === 'conservative'
77-
? ['utilities']
78-
: _.get(config, 'purge.layers', ['base', 'components', 'utilities'])
62+
const layers = _.get(config, 'purge.layers', ['base', 'components', 'utilities'])
7963

8064
css.walkComments((comment) => {
8165
switch (comment.text.trim()) {

0 commit comments

Comments
 (0)