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

Commit 38ca21e

Browse files
author
Brandon Pittman
committed
Remove PurgeCSS feature in favor of Tailwind's built-in Purge.
1 parent 66a5ab9 commit 38ca21e

File tree

3 files changed

+9
-101
lines changed

3 files changed

+9
-101
lines changed

README.md

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
This plugin will add [Tailwind](http://tailwindcss.com) to your
44
[Gridsome](http://gridsome.org) project.
55

6-
**Currently working on v3, which will remove PurgeCSS capabilities**
7-
8-
*(because Tailwind 1.4+ has it baked in)*
9-
106
## Who This Is For
117

128
If you want to set up Tailwind with the least amount of effort in a Gridsome
13-
project, this is for you. If you want to lean in to the *Way of
14-
Tailwind*—using `tailwind.config.js` or keep your CSS inside your Vue
9+
project, this is for you. If you want to lean in to the _Way of
10+
Tailwind_—using `tailwind.config.js` or keep your CSS inside your Vue
1511
files' style blocks—this is the plugin for you. If you want to have a
1612
global CSS file and dump a bunch of crap in there, you'll wind up fighting this
1713
plugin.
@@ -20,7 +16,6 @@ plugin.
2016

2117
`npm install -D gridsome-plugin-tailwindcss`
2218

23-
2419
## Usage
2520

2621
I've gone ahead and automatically imported the default `tailwind.css` file from
@@ -36,8 +31,7 @@ You may be wondering, "Where do I add global CSS?!" Short answer, you don't.
3631
Long answer, read the Tailwind docs on [creating plugins][plugins] and use
3732
`tailwind.config.js` to add base styles and create components/utilities there.
3833

39-
**If you need to create `tailwind.config.js`, run `./node_modules/.bin/tailwind
40-
init` to create one.**
34+
**If you need to create `tailwind.config.js`, run `./node_modules/.bin/tailwind init` to create one.**
4135

4236
[plugins]: https://tailwindcss.com/docs/plugins/#app
4337

@@ -49,55 +43,29 @@ Set any options you want to set in `gridsome.config.js`.
4943
module.exports = {
5044
plugins: [
5145
{
52-
use: 'gridsome-plugin-tailwindcss',
46+
use: "gridsome-plugin-tailwindcss",
5347
/**
5448
* These are the default options. You don't need to set any options to get
5549
* going. Seriously, you don't need to declare tailwind.config.js.
5650
5751
options: {
5852
tailwindConfig: './tailwind.config.js',
59-
purgeConfig: {},
6053
presetEnvConfig: {},
61-
shouldPurge: true,
6254
shouldImport: true,
6355
shouldTimeTravel: true
6456
}
6557
*/
66-
}
67-
]
68-
}
58+
},
59+
],
60+
};
6961
```
7062

7163
**If you don't supply a config file path, Tailwind defaults will be used.**
7264

73-
74-
7565
## Plugins
7666

7767
The following PostCSS plugins are also included with this plugin:
7868

79-
### PurgeCSS
80-
81-
[PurgeCSS](https://www.purgecss.com/with-postcss) is enabled by default. If
82-
you'd like to disable it, pass `shouldPurge:false` to the plugin options
83-
object.
84-
85-
### postcss-import
86-
87-
[postcss-import](https://github.com/postcss/postcss-import) included by
88-
default. Pass `shouldImport: false` to disable.
89-
90-
### postcss-preset-env
91-
92-
[postcss-preset-env](https://github.com/csstools/postcss-preset-env) included
93-
by default. Pass `shouldTimeTravel: false` to disable. You may also pass a
94-
config object to the plugin as `presetEnvConfig`.
95-
96-
With this one plugin, you should be ready to use Tailwind right away. Keep your
97-
customization to `tailwind.config.js` whenever possible, but you can use the
98-
full power of Tailwind (including `@apply`) in your Vue components when
99-
necessary.
100-
10169
## Examples
10270

10371
- [🍸 Aperitif — A delectable starter template for your next Gridsome project.](https://github.com/brandonpittman/aperitif)

gridsome.server.js

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
function TailwindPlugin(api, options) {
22
const {
33
tailwindConfig,
4-
purgeConfig,
54
presetEnvConfig,
65
importUrlConfig,
76
shouldImport,
8-
shouldPurge,
97
shouldTimeTravel,
108
} = options;
119

@@ -35,21 +33,13 @@ function TailwindPlugin(api, options) {
3533
);
3634
}
3735

38-
// eslint-disable-next-line no-unused-expressions
39-
if (process.env.NODE_ENV === "production" && shouldPurge) {
40-
options.plugins.push(
41-
require("@fullhuman/postcss-purgecss")(purgeConfig)
42-
);
43-
}
44-
4536
return options;
4637
});
4738
});
4839
});
4940
}
5041

5142
TailwindPlugin.defaultOptions = () => ({
52-
shouldPurge: true,
5343
shouldImport: true,
5444
shouldTimeTravel: true,
5545
importUrlConfig: {
@@ -64,54 +54,6 @@ TailwindPlugin.defaultOptions = () => ({
6454
"focus-within-pseudo-class": false,
6555
},
6656
},
67-
purgeConfig: {
68-
keyframes: true,
69-
content: [
70-
"./src/**/*.vue",
71-
"./src/**/*.js",
72-
"./src/**/*.jsx",
73-
"./src/**/*.ts",
74-
"./src/**/*.tsx",
75-
"./src/**/*.html",
76-
"./src/**/*.pug",
77-
"./src/**/*.md",
78-
"./src/**/*.svg",
79-
],
80-
whitelist: [
81-
"body",
82-
"html",
83-
"img",
84-
"a",
85-
"g-image",
86-
"g-image--lazy",
87-
"g-image--loaded",
88-
"active",
89-
"active--exact",
90-
],
91-
whitelistPatterns: [
92-
/shiki/,
93-
/prism/,
94-
/token$/,
95-
/markdown/,
96-
/rich-text/,
97-
/richtext/,
98-
/.*-(enter|enter-active|enter-to|leave|leave-active|leave-to)/,
99-
/data-v-.*/,
100-
/>>>/,
101-
/::v-deep/,
102-
],
103-
104-
// This is the function used to extract class names from your templates
105-
defaultExtractor: (content) => {
106-
// Capture as liberally as possible, including things like `h-(screen-1.5)`
107-
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [];
108-
109-
// Capture classes within other delimiters like .block(class="w-1/2") in Pug
110-
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || [];
111-
112-
return broadMatches.concat(innerMatches);
113-
},
114-
},
11557
});
11658

11759
module.exports = TailwindPlugin;

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gridsome-plugin-tailwindcss",
3-
"version": "2.2.48",
3+
"version": "3.0.1",
44
"description": "Add Tailwind to a Gridsome project.",
55
"main": "gridsome.server.js",
66
"files": [
@@ -17,7 +17,6 @@
1717
"gridsome-plugin",
1818
"tailwindcss",
1919
"postcss",
20-
"purgecss",
2120
"postcss-import",
2221
"postcss-preset-env"
2322
],
@@ -28,8 +27,7 @@
2827
},
2928
"homepage": "https://github.com/brandonpittman/gridsome-plugin-tailwindcss#readme",
3029
"dependencies": {
31-
"@fullhuman/postcss-purgecss": "^2.1.2",
32-
"postcss": "^7.0.27",
30+
"postcss": "^7.0.32",
3331
"postcss-import": "^12.0.1",
3432
"postcss-import-url": "^5.1.0",
3533
"postcss-preset-env": "^6.7.0",

0 commit comments

Comments
 (0)