Skip to content

Commit 1dcf233

Browse files
committed
add test for purgecss pattern resolution
1 parent 1e282bf commit 1dcf233

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

tests/fixtures/custom-purge-config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
purge: ['./*.html'],
3+
theme: {
4+
extend: {
5+
colors: {
6+
'black!': '#000',
7+
},
8+
spacing: {
9+
1.5: '0.375rem',
10+
'(1/2+8)': 'calc(50% + 2rem)',
11+
},
12+
minHeight: {
13+
'(screen-4)': 'calc(100vh - 1rem)',
14+
},
15+
fontFamily: {
16+
'%#$@': 'Comic Sans',
17+
},
18+
},
19+
},
20+
}

tests/purgeUnusedStyles.test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import postcss from 'postcss'
44
import tailwind from '../src/index'
55
import { tailwindExtractor } from '../src/lib/purgeUnusedStyles'
66
import defaultConfig from '../stubs/defaultConfig.stub.js'
7+
import customConfig from './fixtures/custom-purge-config.js'
78

89
function suppressConsoleLogs(cb, type = 'warn') {
910
return () => {
@@ -40,23 +41,7 @@ async function inProduction(callback) {
4041

4142
const config = {
4243
...defaultConfig,
43-
theme: {
44-
extend: {
45-
colors: {
46-
'black!': '#000',
47-
},
48-
spacing: {
49-
1.5: '0.375rem',
50-
'(1/2+8)': 'calc(50% + 2rem)',
51-
},
52-
minHeight: {
53-
'(screen-4)': 'calc(100vh - 1rem)',
54-
},
55-
fontFamily: {
56-
'%#$@': 'Comic Sans',
57-
},
58-
},
59-
},
44+
...customConfig,
6045
}
6146

6247
delete config.presets
@@ -116,6 +101,21 @@ test('purges unused classes', () => {
116101
)
117102
})
118103

104+
test.skip('purge patterns are resolved relative to the config file', () => {
105+
return inProduction(
106+
suppressConsoleLogs(() => {
107+
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
108+
const input = fs.readFileSync(inputPath, 'utf8')
109+
110+
return postcss([tailwind(path.resolve(`${__dirname}/fixtures/custom-purge-config.js`))])
111+
.process(input, { from: inputPath })
112+
.then((result) => {
113+
assertPurged(result)
114+
})
115+
})
116+
)
117+
})
118+
119119
test('custom css is not purged by default', () => {
120120
return inProduction(
121121
suppressConsoleLogs(() => {

0 commit comments

Comments
 (0)