Skip to content

Commit 3dba75e

Browse files
feat: add nuxt.config.js to paths to purge classes used there
1 parent c9ea7e3 commit 3dba75e

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

lib/module.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ function nuxtPurgeCss (moduleOptions) {
2222
'components/**/*.vue',
2323
'layouts/**/*.vue',
2424
'pages/**/*.vue',
25-
'plugins/**/*.js'
25+
'plugins/**/*.js',
26+
'nuxt.config.js'
2627
],
2728
styleExtensions: ['.css'],
2829
whitelist: ['body', 'html', 'nuxt-progress', '__nuxt', '__layout'],

test/fixture/assets/a.css

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,75 @@
11
h1 {
2-
color: red
2+
color: red
33
}
44

55
.unused {
6-
color: blue
6+
color: blue
77
}
88

99
.custom {
10-
color: green
10+
color: green
1111
}
1212

1313
.whitelist {
14-
color: black
14+
color: black
1515
}
1616

1717
.pattern-a {
18-
color: red
18+
color: red
19+
}
20+
21+
.nuxt-config-class {
22+
color: lightblue
1923
}
2024

2125
.v-enter {
22-
color: pink
26+
color: pink
2327
}
2428

2529
/* Default Vue Transitions */
2630

2731
.v-enter-active {
28-
color: violet
32+
color: violet
2933
}
3034

3135
.v-enter-to {
32-
color: yellow
36+
color: yellow
3337
}
3438

3539
.v-leave {
36-
color: aqua
40+
color: aqua
3741
}
3842

3943
.v-leave-active {
40-
color: magenta
44+
color: magenta
4145
}
4246

4347
.v-leave-to {
44-
color: brown
48+
color: brown
4549
}
4650

4751
/* Named Vue Transitions */
4852

4953
.named-transition-enter {
50-
color: pink
54+
color: pink
5155
}
5256

5357
.named-transition-enter-active {
54-
color: violet
58+
color: violet
5559
}
5660

5761
.named-transition-enter-to {
58-
color: yellow
62+
color: yellow
5963
}
6064

6165
.named-transition-leave {
62-
color: aqua
66+
color: aqua
6367
}
6468

6569
.named-transition-leave-active {
66-
color: magenta
70+
color: magenta
6771
}
6872

6973
.named-transition-leave-to {
70-
color: brown
74+
color: brown
7175
}

test/fixture/nuxt.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// THIS IS A DUMMY FILE TO ENSURE CLASSES ARE TAKEN INTO ACCOUNT HERE
2+
export default {
3+
bodyAttrs: {
4+
class: 'nuxt-config-class'
5+
}
6+
}

test/module.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('nuxt-purgecss', () => {
144144

145145
const actualGlobalCSS = await getGlobalCSS('js')
146146
const expectedGlobalCSS = {
147-
matching: ['h1{color:red}'],
147+
matching: ['h1{color:red}', 'nuxt-config-class{'],
148148
notMatching: ['.unused', '.custom{', '.whitelist', '.pattern-a']
149149
}
150150

0 commit comments

Comments
 (0)