Skip to content

Commit c17dcca

Browse files
Update readme
1 parent 7dcb7de commit c17dcca

File tree

1 file changed

+64
-13
lines changed

1 file changed

+64
-13
lines changed

README.md

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44
[![Latest Version on NPM](https://img.shields.io/npm/v/laravel-mix-purgecss.svg?style=flat-square)](https://npmjs.com/package/laravel-mix-purgecss)
55
[![npm](https://img.shields.io/npm/dt/laravel-mix-purgecss.svg?style=flat-square)](https://www.npmjs.com/package/laravel-mix-purgecss)
66

7-
---
8-
9-
🚨🚨🚨
10-
11-
**WARNING!** This is the `master` branch of `laravel-mix-purgecss`. The latest stable release is version [4.1.0](https://github.com/spatie/laravel-mix-purgecss/tree/4.1.0).
12-
13-
🚨🚨🚨
14-
15-
---
16-
177
This package adds a `purgeCss` option to Laravel Mix, which installs PurgeCSS for you with a set of sensible defaults for Laravel applications.
188

199
```js
@@ -27,6 +17,12 @@ mix.js('resources/js/app.js', 'public/js')
2717
.purgeCss();
2818
```
2919

20+
## Support us
21+
22+
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
23+
24+
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
25+
3026
## Installation
3127

3228
Before you get started, make sure you're using `laravel-mix` version 5.0.0 or higher.
@@ -68,9 +64,44 @@ mix.js('resources/js/app.js', 'public/js')
6864
});
6965
```
7066

71-
## PurgeCSS customization
67+
### Important notice for `mix.postCss` or `postcss.config.js` users
68+
69+
When you use `mix.postCss()` or a seperate `postcss.config.js` file, Mix _overrides_ all other PostCSS plugins, including the PurgeCSS instance added by this plugin.
70+
71+
To work around this issue, either:
72+
73+
1) Include your PostCSS plugins with `mix.options()`
7274

73-
Our [`defaultConfig`](https://github.com/spatie/laravel-mix-purgecss/blob/master/src/defaultConfig.js) file contains a set of sensible defaults for Laravel applications.
75+
```diff
76+
const mix = require('laravel-mix');
77+
require('laravel-mix-purgecss');
78+
79+
mix.js('resources/js/app.js', 'public/js')
80+
- .postCss('resources/sass/app.css', 'public/css', [
81+
- require('tailwindcss')(),
82+
- ])
83+
+ .postCss('resources/sass/app.css', 'public/css')
84+
+ .options({
85+
+ postCss: [require('tailwindcss')]
86+
+ })
87+
.purgeCss();
88+
```
89+
90+
2) Don't use this package, and use [`postcss-purgecss-laravel`](https://github.com/spatie/postcss-purgecss-laravel) instead
91+
92+
```diff
93+
const mix = require('laravel-mix');
94+
- require('laravel-mix-purgecss');
95+
96+
mix.js('resources/js/app.js', 'public/js')
97+
.postCss('resources/sass/app.css', 'public/css', [
98+
require('tailwindcss')(),
99+
+ require('postcss-purgecss-laravel')({ /* ... */ }),
100+
])
101+
.purgeCss();
102+
```
103+
104+
## PurgeCSS customization
74105

75106
Custom options can be passed when calling PurgeCSS if necessary. Visit PurgeCSS' [docs](https://purgecss.com/configuration.html#options) to learn more about the available options.
76107

@@ -83,7 +114,7 @@ mix.js('resources/js/app.js', 'public/js')
83114
});
84115
```
85116

86-
Passing options will **override** the package defaults. If you want to **extend** the package defaults, wrap them in an `extend` object.
117+
Passing options will _override_ the package defaults. If you want to _extend_ the package defaults, wrap them in an `extend` object.
87118

88119
```js
89120
mix.js('resources/js/app.js', 'public/js')
@@ -96,6 +127,26 @@ mix.js('resources/js/app.js', 'public/js')
96127
});
97128
```
98129

130+
This package uses [`postcss-purgecss-laravel`](https://github.com/spatie/postcss-purgecss-laravel) under the hood, which has the following defaults:
131+
132+
```js
133+
const defaultConfig = {
134+
content: [
135+
"app/**/*.php",
136+
"resources/**/*.html",
137+
"resources/**/*.js",
138+
"resources/**/*.jsx",
139+
"resources/**/*.ts",
140+
"resources/**/*.tsx",
141+
"resources/**/*.php",
142+
"resources/**/*.vue",
143+
"resources/**/*.twig",
144+
],
145+
defaultExtractor: (content) => content.match(/[\w-/.:]+(?<!:)/g) || [],
146+
whitelistPatterns: [/-active$/, /-enter$/, /-leave-to$/, /show$/],
147+
}
148+
```
149+
99150
### Changelog
100151

101152
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

0 commit comments

Comments
 (0)