Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/src/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
display: block;
}


:root {
--custom-var-value: red;
}

.class-\[custom\] {
background: red;
}
Expand All @@ -20,4 +25,8 @@

.should-be-removed {
background: yellow;
}

.\[color\:var\(--custom-var-value\)\] {
color: var(--custom-var-value);
}
2 changes: 1 addition & 1 deletion tests/src/Purge.njs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Purge extends Nullstack {

render() {
return (
<div class="class class-[custom] class-0.5"> Purge </div>
<div class="class class-[custom] [color:var(--custom-var-value)] class-0.5"> Purge </div>
)
}

Expand Down
5 changes: 5 additions & 0 deletions tests/src/Purge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ describe('.production', () => {
expect(hasClass).toBeTruthy();
})

test('used classes with arbitraty value and variable stay after purge', async () => {
const hasClass = css.includes('\\[color\\:var\\(--custom-var-value\\)\\]')
expect(hasClass).toBeTruthy();
})

test('used classes with dots stay after purge', async () => {
const hasClass = css.includes('.class-0\\.5')
expect(hasClass).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function client(env, argv) {
paths: glob.sync(`src/**/*`, { nodir: true }),
content: ['./**/*.njs'],
safelist: ['script', 'body', 'html', 'style'],
defaultExtractor: content => content.match(/[\w-/:\\\.\[\]]+(?<!:)/g) || [],
defaultExtractor: content => content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [],
}));
}
return {
Expand Down