Skip to content

Commit fc7c72d

Browse files
committed
Adding documentation that extractCSS is needed, and an alternative
1 parent 1c2ec8c commit fc7c72d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

guides/nuxt.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ const glob = require('glob-all')
2929
const path = require('path')
3030
```
3131

32+
line 31
33+
34+
```javascript
35+
extractCSS: true
36+
```
37+
3238
line 44
3339

3440
```javascript
@@ -52,3 +58,31 @@ if (!isDev) {
5258

5359
This example is importing the tachyons css framework. Without purgecss, the base css file size is **88.2 kB**. Using purgecss, the base css file is **1.56 kB**
5460

61+
## Alternatives
62+
63+
Using the *extractCSS* option Nuxt will create CSS files that will be loaded separately by the browser.
64+
When generating your application this might be a lot of small files.
65+
66+
To include the CSS into the header of the HTML file you'll need to run the following commands.
67+
Please note that using this configuration purgecss will be active in production and development mode.
68+
69+
```text
70+
npm i --save-dev @fullhuman/postcss-purgecss
71+
```
72+
73+
```javascript
74+
import purgecss from '@fullhuman/postcss-purgecss'
75+
```
76+
77+
```javascript
78+
build: {
79+
postcss: {
80+
plugins: [
81+
purgecss({
82+
content: ['./pages/**/*.vue', './layouts/**/*.vue', './components/**/*.vue'],
83+
whitelist: ['html', 'body'],
84+
})
85+
]
86+
}
87+
}
88+
```

0 commit comments

Comments
 (0)