gulp-purgecss 4.1.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/gulp-purgecss.d.ts +154 -61
- package/lib/gulp-purgecss.esm.js +1 -1
- package/lib/gulp-purgecss.js +1 -1
- package/package.json +10 -8
- package/LICENSE +0 -21
- package/lib/gulp-purgecss.esm.d.ts +0 -61
package/lib/gulp-purgecss.d.ts
CHANGED
|
@@ -1,61 +1,154 @@
|
|
|
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
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
import * as internal from 'stream';
|
|
4
|
+
import * as postcss from 'postcss';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
declare type ComplexSafelist = {
|
|
10
|
+
standard?: StringRegExpArray;
|
|
11
|
+
/**
|
|
12
|
+
* You can safelist selectors and their children based on a regular
|
|
13
|
+
* expression with `safelist.deep`
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const purgecss = await new PurgeCSS().purge({
|
|
19
|
+
* content: [],
|
|
20
|
+
* css: [],
|
|
21
|
+
* safelist: {
|
|
22
|
+
* deep: [/red$/]
|
|
23
|
+
* }
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* In this example, selectors such as `.bg-red .child-of-bg` will be left
|
|
28
|
+
* in the final CSS, even if `child-of-bg` is not found.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
deep?: RegExp[];
|
|
32
|
+
greedy?: RegExp[];
|
|
33
|
+
variables?: StringRegExpArray;
|
|
34
|
+
keyframes?: StringRegExpArray;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
declare type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
declare type ExtractorResult = ExtractorResultDetailed | string[];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
declare interface ExtractorResultDetailed {
|
|
51
|
+
attributes: {
|
|
52
|
+
names: string[];
|
|
53
|
+
values: string[];
|
|
54
|
+
};
|
|
55
|
+
classes: string[];
|
|
56
|
+
ids: string[];
|
|
57
|
+
tags: string[];
|
|
58
|
+
undetermined: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
declare interface Extractors {
|
|
65
|
+
extensions: string[];
|
|
66
|
+
extractor: ExtractorFunction;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param options - options
|
|
72
|
+
* @returns
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
declare function gulpPurgeCSS(options: UserDefinedOptions): internal.Transform;
|
|
77
|
+
export default gulpPurgeCSS;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
declare interface RawContent<T = string> {
|
|
83
|
+
extension: string;
|
|
84
|
+
raw: T;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
declare interface RawCSS {
|
|
91
|
+
raw: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
declare type StringRegExpArray = Array<RegExp | string>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare interface UserDefinedOptions extends Omit<UserDefinedOptions_2, "css" | "content"> {
|
|
104
|
+
content: string[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Options used by PurgeCSS to remove unused CSS
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
declare interface UserDefinedOptions_2 {
|
|
113
|
+
/** {@inheritDoc Options.content} */
|
|
114
|
+
content: Array<string | RawContent>;
|
|
115
|
+
/** {@inheritDoc Options.css} */
|
|
116
|
+
css: Array<string | RawCSS>;
|
|
117
|
+
/** {@inheritDoc Options.defaultExtractor} */
|
|
118
|
+
defaultExtractor?: ExtractorFunction;
|
|
119
|
+
/** {@inheritDoc Options.extractors} */
|
|
120
|
+
extractors?: Array<Extractors>;
|
|
121
|
+
/** {@inheritDoc Options.fontFace} */
|
|
122
|
+
fontFace?: boolean;
|
|
123
|
+
/** {@inheritDoc Options.keyframes} */
|
|
124
|
+
keyframes?: boolean;
|
|
125
|
+
/** {@inheritDoc Options.output} */
|
|
126
|
+
output?: string;
|
|
127
|
+
/** {@inheritDoc Options.rejected} */
|
|
128
|
+
rejected?: boolean;
|
|
129
|
+
/** {@inheritDoc Options.rejectedCss} */
|
|
130
|
+
rejectedCss?: boolean;
|
|
131
|
+
/** {@inheritDoc Options.sourceMap } */
|
|
132
|
+
sourceMap?: boolean | (postcss.SourceMapOptions & { to?: string });
|
|
133
|
+
/** {@inheritDoc Options.stdin} */
|
|
134
|
+
stdin?: boolean;
|
|
135
|
+
/** {@inheritDoc Options.stdout} */
|
|
136
|
+
stdout?: boolean;
|
|
137
|
+
/** {@inheritDoc Options.variables} */
|
|
138
|
+
variables?: boolean;
|
|
139
|
+
/** {@inheritDoc Options.safelist} */
|
|
140
|
+
safelist?: UserDefinedSafelist;
|
|
141
|
+
/** {@inheritDoc Options.blocklist} */
|
|
142
|
+
blocklist?: StringRegExpArray;
|
|
143
|
+
/** {@inheritDoc Options.skippedContentGlobs} */
|
|
144
|
+
skippedContentGlobs?: Array<string>;
|
|
145
|
+
/** {@inheritDoc Options.dynamicAttributes} */
|
|
146
|
+
dynamicAttributes?: string[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
|
153
|
+
|
|
154
|
+
export { }
|
package/lib/gulp-purgecss.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"glob";import
|
|
1
|
+
import*as e from"glob";import r from"plugin-error";import{PurgeCSS as t}from"purgecss";import o from"through2";import n from"vinyl-sourcemaps-apply";function s(s){return o.obj((async function(c,u,i){if(c.isNull())return i(null,c);if(c.isBuffer())try{const r={...s,content:(a=s.content,p=s.skippedContentGlobs,a.reduce(((r,t)=>[...r,...e.sync(t,{ignore:p})]),[])),css:[{raw:c.contents.toString()}],stdin:!0,sourceMap:!!c.sourceMap},o=(await(new t).purge(r))[0],u=r.rejected&&o.rejected?o.rejected.join(" {}\n")+" {}":o.css;c.contents=Buffer.from(u,"utf-8"),c.sourceMap&&n(c,o.sourceMap),i(null,c)}catch(e){e instanceof Error&&this.emit("error",new r("gulp-purgecss",e.message))}var a,p;if(c.isStream()){let e="";c.contents.on("data",(r=>{e+=r.toString()})).on("end",(async()=>{try{const r={...s,css:[{raw:e}],sourceMap:!!c.sourceMap},u=(await(new t).purge(r))[0],a=r.rejected&&u.rejected?u.rejected.join(" {}\n")+" {}":u.css,p=o();p.write(Buffer.from(a,"utf-8")),c.contents=c.contents.pipe(p),c.sourceMap&&n(c,u.sourceMap),i(null,c)}catch(e){e instanceof Error&&this.emit("error",new r("gulp-purgecss",e.message))}}))}}))}export{s as default};
|
package/lib/gulp-purgecss.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("glob"),
|
|
1
|
+
"use strict";var e=require("glob"),r=require("plugin-error"),t=require("purgecss"),n=require("through2"),u=require("vinyl-sourcemaps-apply");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var s=o(e),a=c(r),i=c(n),f=c(u);module.exports=function(e){return i.default.obj((async function(r,n,u){if(r.isNull())return u(null,r);if(r.isBuffer())try{const n={...e,content:(c=e.content,o=e.skippedContentGlobs,c.reduce(((e,r)=>[...e,...s.sync(r,{ignore:o})]),[])),css:[{raw:r.contents.toString()}],stdin:!0,sourceMap:!!r.sourceMap},a=(await(new t.PurgeCSS).purge(n))[0],i=n.rejected&&a.rejected?a.rejected.join(" {}\n")+" {}":a.css;r.contents=Buffer.from(i,"utf-8"),r.sourceMap&&f.default(r,a.sourceMap),u(null,r)}catch(e){e instanceof Error&&this.emit("error",new a.default("gulp-purgecss",e.message))}var c,o;if(r.isStream()){let n="";r.contents.on("data",(e=>{n+=e.toString()})).on("end",(async()=>{try{const c={...e,css:[{raw:n}],sourceMap:!!r.sourceMap},o=(await(new t.PurgeCSS).purge(c))[0],s=c.rejected&&o.rejected?o.rejected.join(" {}\n")+" {}":o.css,a=i.default();a.write(Buffer.from(s,"utf-8")),r.contents=r.contents.pipe(a),r.sourceMap&&f.default(r,o.sourceMap),u(null,r)}catch(e){e instanceof Error&&this.emit("error",new a.default("gulp-purgecss",e.message))}}))}}))};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gulp-purgecss",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Gulp plugin for purgecss",
|
|
5
5
|
"author": "Ffloriel",
|
|
6
6
|
"homepage": "https://purgecss.com",
|
|
@@ -32,20 +32,23 @@
|
|
|
32
32
|
"url": "git+https://github.com/FullHuman/purgecss.git"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"
|
|
35
|
+
"build": "ts-node build.ts",
|
|
36
|
+
"test": "jest"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"glob": "^
|
|
39
|
-
"plugin-error": "^
|
|
40
|
-
"purgecss": "^
|
|
39
|
+
"glob": "^8.0.3",
|
|
40
|
+
"plugin-error": "^2.0.0",
|
|
41
|
+
"purgecss": "^5.0.0",
|
|
41
42
|
"through2": "^4.0.1"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/event-stream": "^4.0.0",
|
|
46
|
+
"@types/glob": "^7.2.0",
|
|
45
47
|
"@types/through2": "^2.0.34",
|
|
46
48
|
"@types/vinyl": "^2.0.4",
|
|
47
49
|
"event-stream": "^4.0.1",
|
|
48
|
-
"vinyl": "^2.2.0"
|
|
50
|
+
"vinyl": "^2.2.0",
|
|
51
|
+
"vinyl-sourcemaps-apply": "^0.2.1"
|
|
49
52
|
},
|
|
50
53
|
"bugs": {
|
|
51
54
|
"url": "https://github.com/FullHuman/purgecss/issues"
|
|
@@ -53,6 +56,5 @@
|
|
|
53
56
|
"publishConfig": {
|
|
54
57
|
"access": "public",
|
|
55
58
|
"registry": "https://registry.npmjs.org/"
|
|
56
|
-
}
|
|
57
|
-
"gitHead": "37e5053a446880d12fd2f55abfc362c3dac9c49c"
|
|
59
|
+
}
|
|
58
60
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Full Human
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import internal from "stream";
|
|
2
|
-
interface RawContent<T = string> {
|
|
3
|
-
extension: string;
|
|
4
|
-
raw: T;
|
|
5
|
-
}
|
|
6
|
-
interface RawCSS {
|
|
7
|
-
raw: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
}
|
|
10
|
-
interface ExtractorResultDetailed {
|
|
11
|
-
attributes: {
|
|
12
|
-
names: string[];
|
|
13
|
-
values: string[];
|
|
14
|
-
};
|
|
15
|
-
classes: string[];
|
|
16
|
-
ids: string[];
|
|
17
|
-
tags: string[];
|
|
18
|
-
undetermined: string[];
|
|
19
|
-
}
|
|
20
|
-
type ExtractorResult = ExtractorResultDetailed | string[];
|
|
21
|
-
type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
|
|
22
|
-
interface Extractors {
|
|
23
|
-
extensions: string[];
|
|
24
|
-
extractor: ExtractorFunction;
|
|
25
|
-
}
|
|
26
|
-
type StringRegExpArray = Array<RegExp | string>;
|
|
27
|
-
type ComplexSafelist = {
|
|
28
|
-
standard?: StringRegExpArray;
|
|
29
|
-
deep?: RegExp[];
|
|
30
|
-
greedy?: RegExp[];
|
|
31
|
-
variables?: StringRegExpArray;
|
|
32
|
-
keyframes?: StringRegExpArray;
|
|
33
|
-
};
|
|
34
|
-
type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
|
35
|
-
interface UserDefinedOptions {
|
|
36
|
-
content: Array<string | RawContent>;
|
|
37
|
-
css: Array<string | RawCSS>;
|
|
38
|
-
defaultExtractor?: ExtractorFunction;
|
|
39
|
-
extractors?: Array<Extractors>;
|
|
40
|
-
fontFace?: boolean;
|
|
41
|
-
keyframes?: boolean;
|
|
42
|
-
output?: string;
|
|
43
|
-
rejected?: boolean;
|
|
44
|
-
rejectedCss?: boolean;
|
|
45
|
-
stdin?: boolean;
|
|
46
|
-
stdout?: boolean;
|
|
47
|
-
variables?: boolean;
|
|
48
|
-
safelist?: UserDefinedSafelist;
|
|
49
|
-
blocklist?: StringRegExpArray;
|
|
50
|
-
skippedContentGlobs?: Array<string>;
|
|
51
|
-
dynamicAttributes?: string[];
|
|
52
|
-
}
|
|
53
|
-
type PurgeCSSUserDefinedOptions = UserDefinedOptions;
|
|
54
|
-
interface UserDefinedOptions$0
|
|
55
|
-
extends Omit<PurgeCSSUserDefinedOptions, "css" | "content"> {
|
|
56
|
-
content: string[];
|
|
57
|
-
}
|
|
58
|
-
declare function gulpPurgeCSS(
|
|
59
|
-
options: UserDefinedOptions$0
|
|
60
|
-
): internal.Transform;
|
|
61
|
-
export { gulpPurgeCSS as default };
|