Skip to content

Commit 9a6629b

Browse files
committed
Add Specify Paths For Purging Unused CSS as a tailwind til
1 parent 12388e8 commit 9a6629b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1212

13-
_1031 TILs and counting..._
13+
_1032 TILs and counting..._
1414

1515
---
1616

@@ -901,6 +901,7 @@ _1031 TILs and counting..._
901901
### Tailwind CSS
902902

903903
- [Base Styles For Text Link](tailwind/base-styles-for-text-link.md)
904+
- [Specify Paths For Purging Unused CSS](tailwind/specify-paths-for-purging-unused-css.md)
904905

905906
### tmux
906907

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Specify Paths For Purging Unused CSS
2+
3+
Tailwind CSS is a full-featured utility class CSS framework. It has just about
4+
everything you need. It also has a bunch of things you probably don't need. And
5+
there is no need to ship the CSS you don't need to the client. Tailwind is able
6+
to exclude the unused CSS through a mechanism called _purging_.
7+
8+
To turn on purging (for _production_) and for Tailwind to know what can be
9+
safely purged, you need to specify one or more _purge paths_ in your
10+
`tailwind.config.js` file. This is a listing of all the places where you use
11+
Tailwind utility classes.
12+
13+
Specify it with an array at the `purge` key:
14+
15+
```javascript
16+
module.exports = {
17+
purge: [
18+
"./src/components/**/*.jsx",
19+
"./pages/**/*.js"
20+
],
21+
darkMode: false,
22+
theme: {
23+
extend: {},
24+
},
25+
variants: {
26+
extend: {},
27+
},
28+
plugins: [],
29+
};
30+
```
31+
32+
Notice that globbed paths can be used as a way of specifying files located in a
33+
nested directory structure. Above I've stated that any `jsx` files located
34+
anywhere under `src/components/` as well as any `js` files located anywhere
35+
under `pages/` should be checked.
36+
37+
[source](https://tailwindcss.com/docs/optimizing-for-production#basic-usage)

0 commit comments

Comments
 (0)