Skip to content

Commit 5dd0972

Browse files
trecentiTheAlexLichter
authored andcommitted
fix: do not purge vue transition css classes (#59)
1 parent 7ad9c8e commit 5dd0972

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

lib/module.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export default function nuxtPurgeCss(moduleOptions) {
2626
],
2727
styleExtensions: ['.css'],
2828
whitelist: ['body', 'html', 'nuxt-progress', '__nuxt', '__layout'],
29-
whitelistPatterns: [],
29+
whitelistPatterns: [
30+
/.*-(enter|enter-active|enter-to|leave|leave-active|leave-to)/
31+
],
3032
whitelistPatternsChildren: [],
3133
extractors: [
3234
{

test/fixture/assets/a.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,55 @@ h1 {
1717
.pattern-a {
1818
color: red
1919
}
20+
21+
.v-enter {
22+
color: pink
23+
}
24+
25+
/* Default Vue Transitions */
26+
27+
.v-enter-active {
28+
color: violet
29+
}
30+
31+
.v-enter-to {
32+
color: yellow
33+
}
34+
35+
.v-leave {
36+
color: aqua
37+
}
38+
39+
.v-leave-active {
40+
color: magenta
41+
}
42+
43+
.v-leave-to {
44+
color: brown
45+
}
46+
47+
/* Named Vue Transitions */
48+
49+
.named-transition-enter {
50+
color: pink
51+
}
52+
53+
.named-transition-enter-active {
54+
color: violet
55+
}
56+
57+
.named-transition-enter-to {
58+
color: yellow
59+
}
60+
61+
.named-transition-leave {
62+
color: aqua
63+
}
64+
65+
.named-transition-leave-active {
66+
color: magenta
67+
}
68+
69+
.named-transition-leave-to {
70+
color: brown
71+
}

test/module.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,32 @@ describe('nuxt-purgecss', () => {
100100
expect(testCSS).not.toMatch('.abc')
101101
expect(testCSS).not.toMatch('.ymca')
102102
})
103+
104+
describe('vue transitions', () => {
105+
test('does not purge vue default transitions', async () => {
106+
nuxt = await setupNuxt(require('./fixture/configs/webpack/default'))
107+
108+
const globalCSS = await getGlobalCSS()
109+
expect(globalCSS).toMatch('.v-enter')
110+
expect(globalCSS).toMatch('.v-enter-active')
111+
expect(globalCSS).toMatch('.v-enter-to')
112+
expect(globalCSS).toMatch('.v-leave')
113+
expect(globalCSS).toMatch('.v-leave-active')
114+
expect(globalCSS).toMatch('.v-leave-to')
115+
})
116+
117+
test('does not purge vue named transitions', async () => {
118+
nuxt = await setupNuxt(require('./fixture/configs/webpack/default'))
119+
120+
const globalCSS = await getGlobalCSS()
121+
expect(globalCSS).toMatch('.named-transition-enter')
122+
expect(globalCSS).toMatch('.named-transition-enter-active')
123+
expect(globalCSS).toMatch('.named-transition-enter-to')
124+
expect(globalCSS).toMatch('.named-transition-leave')
125+
expect(globalCSS).toMatch('.named-transition-leave-active')
126+
expect(globalCSS).toMatch('.named-transition-leave-to')
127+
})
128+
})
103129
})
104130
describe('postcss', () => {
105131
test('purge css by default', async () => {

0 commit comments

Comments
 (0)