Skip to content
This repository was archived by the owner on May 8, 2021. It is now read-only.

Commit 5e67036

Browse files
authored
Add PurgeCSS explanation to README.md
1 parent b5d0522 commit 5e67036

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

examples/nextjs/README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
To add Tailwind to a Next (^9.2.0) project, start by installing `tailwindcss`, `postcss-import` and `autoprefixer`:
44

55
```sh
6-
npm install tailwindcss postcss-import autoprefixer
6+
npm install tailwindcss postcss-import autoprefixer --save
77
```
88

99
Next, set up your PostCSS plugins by creating a `postcss.config.js` file and adding the following configuration:
@@ -43,3 +43,32 @@ class MyApp extends App {
4343

4444
export default MyApp
4545
```
46+
## Setting up Purgecss (optional)
47+
To add Purgecss, start by installing `@fullhuman/postcss-purgecss`.
48+
49+
```sh
50+
npm install @fullhuman/postcss-purgecss --save
51+
```
52+
53+
Finally, add Purgecss to PostCSS plugins by updating the `postcss.config.js` file and adding the following configuration:
54+
55+
```js
56+
const purgecss = [
57+
"@fullhuman/postcss-purgecss",
58+
{
59+
content: ["./components/**/*.js", "./pages/**/*.js"],
60+
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || []
61+
}
62+
];
63+
module.exports = {
64+
plugins: [
65+
"postcss-import",
66+
"tailwindcss",
67+
"autoprefixer",
68+
...(process.env.NODE_ENV === "production" ? [purgecss] : [])
69+
]
70+
};
71+
72+
```
73+
74+
[Learn more about using Purgecss with Tailwind here.](https://tailwindcss.com/docs/controlling-file-size#setting-up-purgecss)

0 commit comments

Comments
 (0)