Skip to content

Commit 4be652d

Browse files
committed
Fix over-purging issue in demo
1 parent 465e35b commit 4be652d

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

demo/tailwind.config.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
1+
const mdx = require('@mdx-js/mdx')
2+
13
module.exports = {
2-
purge: ['./demo/pages/**/*.{js,mdx}', './demo/components/**/*.{js,mdx}'],
4+
purge: {
5+
mode: 'all',
6+
content: ['./demo/pages/**/*.{js,mdx}', './demo/components/**/*.{js,mdx}'],
7+
options: {
8+
whitelist: ['html', 'body'],
9+
extractors: [
10+
{
11+
extensions: ['mdx'],
12+
extractor: (content) => {
13+
content = mdx.sync(content)
14+
15+
// Capture as liberally as possible, including things like `h-(screen-1.5)`
16+
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []
17+
18+
// Capture classes within other delimiters like .block(class="w-1/2") in Pug
19+
const innerMatches =
20+
content.match(/[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g) || []
21+
22+
return broadMatches.concat(innerMatches)
23+
},
24+
},
25+
],
26+
},
27+
},
328
theme: {},
429
variants: {},
530
plugins: [require('../src/index.js')],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"devDependencies": {
2020
"@mdx-js/loader": "^1.0.19",
21+
"@mdx-js/mdx": "^1.6.6",
2122
"@next/mdx": "^8.1.0",
2223
"autoprefixer": "^9.6.1",
2324
"clean-css": "^4.2.1",

0 commit comments

Comments
 (0)