Skip to content

Commit

Permalink
Remove 'conservative' purge mode
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Oct 18, 2020
1 parent 4959a99 commit b008d0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 95 deletions.
70 changes: 0 additions & 70 deletions __tests__/purgeUnusedStyles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,30 +389,6 @@ test('you can purge just base and component layers (but why)', () => {
)
})

test('does not purge components when mode is conservative', () => {
return inProduction(
suppressConsoleLogs(() => {
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
const input = fs.readFileSync(inputPath, 'utf8')

return postcss([
tailwind({
...config,
purge: {
mode: 'conservative',
content: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
},
}),
])
.process(input, { from: inputPath })
.then((result) => {
expect(result.css).toContain('.container')
assertPurged(result)
})
})
)
})

test('extra purgecss control comments can be added manually', () => {
return inProduction(
suppressConsoleLogs(() => {
Expand Down Expand Up @@ -632,52 +608,6 @@ test(
})
)

test('the `conservative` mode can be set explicitly', () => {
return inProduction(
suppressConsoleLogs(() => {
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
const input = fs.readFileSync(inputPath, 'utf8')

return postcss([
tailwind({
...config,
purge: {
mode: 'conservative',
content: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
},
}),
])
.process(input, { from: inputPath })
.then((result) => {
expect(result.css).not.toContain('.bg-red-600')
expect(result.css).not.toContain('.w-1\\/3')
expect(result.css).not.toContain('.flex')
expect(result.css).not.toContain('.font-sans')
expect(result.css).not.toContain('.text-right')
expect(result.css).not.toContain('.px-4')
expect(result.css).not.toContain('.h-full')

expect(result.css).toContain('.bg-red-500')
expect(result.css).toContain('.md\\:bg-blue-300')
expect(result.css).toContain('.w-1\\/2')
expect(result.css).toContain('.block')
expect(result.css).toContain('.md\\:flow-root')
expect(result.css).toContain('.h-screen')
expect(result.css).toContain('.min-h-\\(screen-4\\)')
expect(result.css).toContain('.bg-black\\!')
expect(result.css).toContain('.font-\\%\\#\\$\\@')
expect(result.css).toContain('.w-\\(1\\/2\\+8\\)')
expect(result.css).toContain('.inline-grid')
expect(result.css).toContain('.grid-cols-3')
expect(result.css).toContain('.px-1\\.5')
expect(result.css).toContain('.col-span-2')
expect(result.css).toContain('.col-span-1')
expect(result.css).toContain('.text-center')
})
})
)
})

test('element selectors are preserved by default', () => {
return inProduction(
suppressConsoleLogs(() => {
Expand Down
7 changes: 1 addition & 6 deletions src/featureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import chalk from 'chalk'
import log from './util/log'

const featureFlags = {
future: [
'purgeLayersByDefault',
'defaultLineHeights',
'standardFontWeights',
'moveTruncateToTextOverflow',
],
future: ['defaultLineHeights', 'standardFontWeights', 'moveTruncateToTextOverflow'],
experimental: [
'uniformColorPalette',
'extendedSpacingScale',
Expand Down
22 changes: 3 additions & 19 deletions src/lib/purgeUnusedStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,17 @@ export default function purgeUnusedUtilities(config, configChanged) {

return postcss([
function (css) {
const mode = _.get(
config,
'purge.mode',
flagEnabled(config, 'purgeLayersByDefault') ? 'layers' : 'conservative'
)
const mode = _.get(config, 'purge.mode', 'layers')

if (!['all', 'layers', 'conservative'].includes(mode)) {
if (!['all', 'layers'].includes(mode)) {
throw new Error('Purge `mode` must be one of `layers` or `all`.')
}

if (mode === 'all') {
return
}

if (mode === 'conservative') {
if (configChanged) {
log.warn([
'The `conservative` purge mode will be removed in Tailwind 2.0.',
'Please switch to the new `layers` mode instead.',
])
}
}

const layers =
mode === 'conservative'
? ['utilities']
: _.get(config, 'purge.layers', ['base', 'components', 'utilities'])
const layers = _.get(config, 'purge.layers', ['base', 'components', 'utilities'])

css.walkComments((comment) => {
switch (comment.text.trim()) {
Expand Down

0 comments on commit b008d0c

Please sign in to comment.