purgecss-webpack-plugin 4.0.2 → 4.1.2
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/README.md
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
# purgecss-webpack-plugin
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/FullHuman/purgecss-webpack-plugin)
|
|
4
|
-
[]()
|
|
5
|
-
[](https://david-dm.org/fullhuman/purgecss-webpack-plugin)
|
|
6
|
-
[](https://david-dm.org/fullhuman/purgecss-webpack-plugin?type=dev)
|
|
7
|
-
[](https://www.codacy.com/app/FullHuman/purgecss-webpack-plugin?utm_source=github.com&utm_medium=referral&utm_content=FullHuman/purgecss-webpack-plugin&utm_campaign=Badge_Grade)
|
|
8
|
-
[](https://www.codacy.com/app/FullHuman/purgecss-webpack-plugin?utm_source=github.com&utm_medium=referral&utm_content=FullHuman/purgecss-webpack-plugin&utm_campaign=Badge_Coverage)
|
|
9
|
-
[](https://github.com/prettier/prettier)
|
|
10
3
|
[](https://www.npmjs.com/package/purgecss-webpack-plugin)
|
|
11
|
-
[]()
|
|
4
|
+
[]()
|
|
12
5
|
|
|
13
6
|
[Webpack](https://github.com/webpack/webpack) plugin to remove unused css.
|
|
14
7
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Compilation, Compiler } from "webpack";
|
|
2
2
|
type StringRegExpArray = Array<RegExp | string>;
|
|
3
3
|
type ComplexSafelist = {
|
|
4
4
|
standard?: StringRegExpArray;
|
|
@@ -30,6 +30,8 @@ interface UserDefinedOptions$0 {
|
|
|
30
30
|
verbose?: boolean;
|
|
31
31
|
safelist?: StringRegExpArray | ComplexSafelist | SafelistFunction;
|
|
32
32
|
blocklist?: StringRegExpArray | BlocklistFunction;
|
|
33
|
+
skippedContentGlobs?: Array<string>;
|
|
34
|
+
dynamicAttributes?: string[];
|
|
33
35
|
only?: string[];
|
|
34
36
|
}
|
|
35
37
|
type PurgedStats = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Compilation, Compiler } from "webpack";
|
|
2
2
|
type StringRegExpArray = Array<RegExp | string>;
|
|
3
3
|
type ComplexSafelist = {
|
|
4
4
|
standard?: StringRegExpArray;
|
|
@@ -30,6 +30,8 @@ interface UserDefinedOptions$0 {
|
|
|
30
30
|
verbose?: boolean;
|
|
31
31
|
safelist?: StringRegExpArray | ComplexSafelist | SafelistFunction;
|
|
32
32
|
blocklist?: StringRegExpArray | BlocklistFunction;
|
|
33
|
+
skippedContentGlobs?: Array<string>;
|
|
34
|
+
dynamicAttributes?: string[];
|
|
33
35
|
only?: string[];
|
|
34
36
|
}
|
|
35
37
|
type PurgedStats = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import*as s from"fs";import t from"path";import o,{defaultOptions as e}from"purgecss";import{ConcatSource as i}from"webpack-sources";const n=[".css",".scss",".styl",".sass",".less"];class r{constructor(s){this.purgedStats={},this.options=s}apply(s){s.hooks.compilation.tap("PurgeCSS",this.initializePlugin.bind(this))}initializePlugin(t){t.hooks.additionalAssets.tapPromise("PurgeCSS",(()=>{const o="function"==typeof this.options.paths?this.options.paths():this.options.paths;return o.forEach((t=>{if(!s.existsSync(t))throw new Error(`Path ${t} does not exist.`)})),this.runPluginHook(t,o)}))}async runPluginHook(s,r){const c=Object.entries(s.assets).filter((([s])=>function(s,o){const e=t.extname((i=s).includes("?")?i.split("?").slice(0,-1).join(""):i);var i;return o.includes(e)}(s,[".css"])));for(const t of s.chunks){const a=c.filter((([s])=>this.options.only?this.options.only.some((t=>s.includes(t))):Array.isArray(t.files)?t.files.includes(s):t.files.has(s)));for(const[t,c]of a){const a=r.filter((s=>!n.some((t=>s.endsWith(t))))),l={...e,...this.options,content:a,css:[{raw:c.source().toString()}]};"function"==typeof l.safelist&&(l.safelist=l.safelist()),"function"==typeof l.blocklist&&(l.blocklist=l.blocklist());const f=(await(new o).purge({content:l.content,css:l.css,defaultExtractor:l.defaultExtractor,extractors:l.extractors,fontFace:l.fontFace,keyframes:l.keyframes,output:l.output,rejected:l.rejected,variables:l.variables,safelist:l.safelist,blocklist:l.blocklist}))[0];f.rejected&&(this.purgedStats[t]=f.rejected),s.updateAsset(t,new i(f.css))}}}}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("fs"),
|
|
1
|
+
"use strict";var t=require("fs"),e=require("path"),s=require("purgecss"),o=require("webpack-sources");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function r(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(s){if("default"!==s){var o=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:function(){return t[s]}})}})),e.default=t,Object.freeze(e)}var n=r(t),c=i(e),a=i(s);const u=[".css",".scss",".styl",".sass",".less"];module.exports=class{constructor(t){this.purgedStats={},this.options=t}apply(t){t.hooks.compilation.tap("PurgeCSS",this.initializePlugin.bind(this))}initializePlugin(t){t.hooks.additionalAssets.tapPromise("PurgeCSS",(()=>{const e="function"==typeof this.options.paths?this.options.paths():this.options.paths;return e.forEach((t=>{if(!n.existsSync(t))throw new Error(`Path ${t} does not exist.`)})),this.runPluginHook(t,e)}))}async runPluginHook(t,e){const i=Object.entries(t.assets).filter((([t])=>function(t,e){const s=c.default.extname((o=t).includes("?")?o.split("?").slice(0,-1).join(""):o);var o;return e.includes(s)}(t,[".css"])));for(const r of t.chunks){const n=i.filter((([t])=>this.options.only?this.options.only.some((e=>t.includes(e))):Array.isArray(r.files)?r.files.includes(t):r.files.has(t)));for(const[i,r]of n){const n=e.filter((t=>!u.some((e=>t.endsWith(e))))),c={...s.defaultOptions,...this.options,content:n,css:[{raw:r.source().toString()}]};"function"==typeof c.safelist&&(c.safelist=c.safelist()),"function"==typeof c.blocklist&&(c.blocklist=c.blocklist());const l=(await(new a.default).purge({content:c.content,css:c.css,defaultExtractor:c.defaultExtractor,extractors:c.extractors,fontFace:c.fontFace,keyframes:c.keyframes,output:c.output,rejected:c.rejected,variables:c.variables,safelist:c.safelist,blocklist:c.blocklist}))[0];l.rejected&&(this.purgedStats[i]=l.rejected),t.updateAsset(i,new o.ConcatSource(l.css))}}}};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "purgecss-webpack-plugin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "PurgeCSS plugin for webpack - Remove unused css",
|
|
5
5
|
"author": "Ffloriel",
|
|
6
6
|
"homepage": "https://purgecss.com",
|
|
@@ -36,20 +36,24 @@
|
|
|
36
36
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"purgecss": "^4.
|
|
39
|
+
"purgecss": "^4.1.2",
|
|
40
40
|
"webpack": "^5.4.0",
|
|
41
|
-
"webpack-sources": "^2.0
|
|
41
|
+
"webpack-sources": "^3.2.0"
|
|
42
42
|
},
|
|
43
43
|
"bugs": {
|
|
44
44
|
"url": "https://github.com/FullHuman/purgecss/issues"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/webpack-sources": "^2.0
|
|
48
|
-
"css-loader": "^
|
|
49
|
-
"mini-css-extract-plugin": "^1.
|
|
47
|
+
"@types/webpack-sources": "^3.2.0",
|
|
48
|
+
"css-loader": "^6.2.0",
|
|
49
|
+
"mini-css-extract-plugin": "^2.1.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"webpack": "*"
|
|
53
53
|
},
|
|
54
|
-
"
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"registry": "https://registry.npmjs.org/"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "1329d96b0ad17e9b2b4d604d1a689856da176a59"
|
|
55
59
|
}
|