mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Merge pull request #1673 from lihbr/fix/purge-enabled-false-eval-to-true
Fix `purgeEnabled` evaluating to true when `config.purge.enabled` is false
This commit is contained in:
commit
67ec21e870
@ -149,6 +149,30 @@ test('does not purge if the array is empty', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('does not purge if explicitly disabled', () => {
|
||||
const OLD_NODE_ENV = process.env.NODE_ENV
|
||||
process.env.NODE_ENV = 'production'
|
||||
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
|
||||
const input = fs.readFileSync(inputPath, 'utf8')
|
||||
|
||||
return postcss([
|
||||
tailwind({
|
||||
...defaultConfig,
|
||||
purge: { enabled: false },
|
||||
}),
|
||||
])
|
||||
.process(input, { from: inputPath })
|
||||
.then(result => {
|
||||
process.env.NODE_ENV = OLD_NODE_ENV
|
||||
const expected = fs.readFileSync(
|
||||
path.resolve(`${__dirname}/fixtures/tailwind-output.css`),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
expect(result.css).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
test('purges outside of production if explicitly enabled', () => {
|
||||
const OLD_NODE_ENV = process.env.NODE_ENV
|
||||
process.env.NODE_ENV = 'development'
|
||||
|
||||
@ -20,9 +20,11 @@ function removeTailwindComments(css) {
|
||||
}
|
||||
|
||||
export default function purgeUnusedUtilities(config) {
|
||||
const purgeEnabled =
|
||||
_.get(config, 'purge.enabled', false) === true ||
|
||||
(config.purge !== undefined && process.env.NODE_ENV === 'production')
|
||||
const purgeEnabled = _.get(
|
||||
config,
|
||||
'purge.enabled',
|
||||
config.purge !== undefined && process.env.NODE_ENV === 'production'
|
||||
)
|
||||
|
||||
if (!purgeEnabled) {
|
||||
return removeTailwindComments
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user