fix(module): reduce css bundle size by fixing safelist regex (#2005)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Yu Zhuohao
2024-08-03 01:02:39 +08:00
committed by GitHub
parent 3485092edb
commit 8ac9ca4978
2 changed files with 78 additions and 70 deletions

View File

@@ -24,17 +24,17 @@ describe('generateSafelist', () => {
[
'default safelist',
{}, [],
['bg-(primary)-50', 'bg-(red)-500'] // these both should be in the safelist
['^bg-(primary)-50$', '^bg-(red)-500$'] // these both should be in the safelist
],
[
'safelisting single new color',
{}, ['myColor'],
'bg-(myColor|primary)-50'
'^bg-(myColor|primary)-50$'
],
[
'reducing amount of theme colors',
{ theme: { colors: { plainBlue: '#00F' } } }, ['plainBlue'],
['bg-(plainBlue|primary)-50', '!', /orange/] // the word "orange" should _not_ be found in any safelist pattern
['^bg-(plainBlue|primary)-50$', '!', /orange/] // the word "orange" should _not_ be found in any safelist pattern
]
])('%s', async (_description, tailwindConfig: Partial<TWConfig>, safelistColors, safelistPatterns) => {
safelistColors.push('primary')