You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The extractor is now a function that takes the content as an argument.
16
-
```js
17
-
classExtractor {
18
-
staticextract(content) {}
19
-
}
20
-
```
21
-
changes to
22
-
```js
23
-
functionextractor(content) {}
24
-
```
25
-
26
-
27
12
## Features
28
13
29
14
* Remove unneeded CSS with ease
@@ -35,51 +20,39 @@ function extractor(content) {}
35
20
36
21
## Setup
37
22
38
-
- Add `nuxt-purgecss` dependency using yarn or npm to your project
39
-
- Add `nuxt-purgecss` to `modules` section of `nuxt.config.js`:
23
+
1. Add `nuxt-purgecss` dependency to your project
24
+
25
+
```bash
26
+
yarn add --dev nuxt-purgecss # or npm install --save-dev nuxt-purgecss
27
+
```
28
+
29
+
2. Add `nuxt-purgecss` to the `buildModules` section of `nuxt.config.js`
40
30
41
31
```js
42
-
{
43
-
modules: [
32
+
exportdefault {
33
+
buildModules: [
34
+
// Simple usage
44
35
'nuxt-purgecss',
45
-
],
46
36
47
-
purgeCSS: {
48
-
// your settings here
49
-
}
37
+
// With options
38
+
['nuxt-purgecss', { /* module options */ }]
39
+
]
50
40
}
51
41
```
52
42
43
+
:warning: If you are using Nuxt **< v2.9** you have to install the module as a `dependency` (No `--dev` or `--save-dev` flags) and use `modules` section in `nuxt.config.js` instead of `buildModules`.
44
+
45
+
53
46
## Options
54
47
55
48
### Defaults
56
49
57
-
Before diving into the individual attributes, here are the default settings of the module:
50
+
Before diving into the individual attributes, please have a look [at the default settings](https://github.com/Developmint/nuxt-purgecss/blob/master/lib/utils.js) of the module.
58
51
59
-
```js
60
-
{
61
-
mode:MODES.webpack,
62
-
enabled: ({ isDev, isClient }) => (!isDev && isClient), // or `false` when in dev/debug mode
63
-
paths: [
64
-
'components/**/*.vue',
65
-
'layouts/**/*.vue',
66
-
'pages/**/*.vue',
67
-
'plugins/**/*.js'
68
-
],
69
-
styleExtensions: ['.css'],
70
-
whitelist: ['body', 'html', 'nuxt-progress'],
71
-
extractors: [
72
-
{
73
-
extractor(content) {
74
-
returncontent.match(/[\w-.:/]+(?<!:)/g)
75
-
},
76
-
extensions: ['html', 'vue', 'js']
77
-
}
78
-
]
79
-
}
80
-
```
52
+
The defaults will scan all your `.vue` or `.js` components in the common Nuxt folders, as well as checking your `nuxt.config.js` for used classes.
53
+
Furthermore, typical classes (like these needed for transitions, the nuxt link ones or those set when using scoped styles) are whitelisted already.
81
54
82
-
This settings should be a good foundation for a variety of projects.
55
+
These settings should be a good foundation for a variety of projects.
83
56
84
57
### Merging defaults
85
58
@@ -94,8 +67,8 @@ the defaults are quite sensible. If you don't want to have the defaults include,
94
67
95
68
#### mode
96
69
97
-
* Type: `String` (webpack or postcss)
98
-
* Default: `webpack`
70
+
* Type: `String` ('webpack' or 'postcss')
71
+
* Default: `postcss`
99
72
100
73
Defines the mode, PurgeCSS should be used in.
101
74
@@ -104,15 +77,11 @@ Defines the mode, PurgeCSS should be used in.
104
77
105
78
#### enabled
106
79
107
-
* Type: `Boolean` or `Function` (only for webpack mode, will receive the build.extend ctx)
108
-
* Default: `({ isDev, isClient }) => (!isDev && isClient)` (only activates in production mode) or `false` in debug/dev mode
0 commit comments