-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.config.js
79 lines (67 loc) · 2.12 KB
/
postcss.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// const tailwindcss = require("tailwindcss");
// const IS_DEVELOPMENT = process.env.NODE_ENV === "development";
// const plugins = [tailwindcss];
// if (!IS_DEVELOPMENT) {
// const purgecss = require("@fullhuman/postcss-purgecss");
// class TailwindExtractor {
// static extract(content) {
// // return content.match(/[A-z0-9-:\/]+/g) || [];
// return content.match(/[A-Za-z0-9-_:/]+/g) || [];
// }
// }
// plugins.push(
// purgecss({
// content: ["./*.html", "./*.js"],
// extractors: [
// {
// extractor: TailwindExtractor,
// extensions: ["html"],
// },
// ],
// })
// );
// }
// module.exports = {
// plugins: plugins,
// };
// const purgecss = require("@fullhuman/postcss-purgecss")({
// // Specify the paths to all of the template files in your project
// content: [
// "./src/**/*.html",
// "./src/**/*.js",
// "./src/**/*.jsx",
// // etc.
// ],
// // Include any special characters you're using in this regular expression
// defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
// });
// module.exports = {
// plugins: [
// require("tailwindcss"),
// require("autoprefixer"),
// ...(process.env.NODE_ENV === "production" ? [purgecss] : []),
// ],
// };
const purgecss = require("@fullhuman/postcss-purgecss")({
// Specify the paths to all of the template files in your project
content: [
"./src/**/*.html",
"./src/**/*.js",
// etc.
],
// This is the function used to extract class names from your templates
defaultExtractor: (content) => {
// Capture as liberally as possible, including things like `h-(screen-1.5)`
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [];
// Capture classes within other delimiters like .block(class="w-1/2") in Pug
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || [];
return broadMatches.concat(innerMatches);
},
});
module.exports = {
plugins: [
require("tailwindcss"),
require("autoprefixer"),
...(process.env.NODE_ENV === "production" ? [purgecss] : []),
],
};