@fullhuman/postcss-purgecss
Advanced tools
Comparing version 4.1.3 to 5.0.0
@@ -1,38 +0,164 @@ | ||
import * as postcss from "postcss"; | ||
type StringRegExpArray = Array<RegExp | string>; | ||
type ComplexSafelist = { | ||
standard?: StringRegExpArray; | ||
deep?: RegExp[]; | ||
greedy?: RegExp[]; | ||
variables?: StringRegExpArray; | ||
keyframes?: StringRegExpArray; | ||
/** | ||
* PostCSS Plugin for PurgeCSS | ||
* | ||
* Most bundlers and frameworks to build websites are using PostCSS. | ||
* The easiest way to configure PurgeCSS is with its PostCSS plugin. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
import * as postcss from 'postcss'; | ||
/** | ||
* @public | ||
*/ | ||
declare type ComplexSafelist = { | ||
standard?: StringRegExpArray; | ||
/** | ||
* You can safelist selectors and their children based on a regular | ||
* expression with `safelist.deep` | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* const purgecss = await new PurgeCSS().purge({ | ||
* content: [], | ||
* css: [], | ||
* safelist: { | ||
* deep: [/red$/] | ||
* } | ||
* }) | ||
* ``` | ||
* | ||
* In this example, selectors such as `.bg-red .child-of-bg` will be left | ||
* in the final CSS, even if `child-of-bg` is not found. | ||
* | ||
*/ | ||
deep?: RegExp[]; | ||
greedy?: RegExp[]; | ||
variables?: StringRegExpArray; | ||
keyframes?: StringRegExpArray; | ||
}; | ||
type UserDefinedSafelist = StringRegExpArray | ComplexSafelist; | ||
interface RawContent$0<T = string> { | ||
extension: string; | ||
raw: T; | ||
/** | ||
* @public | ||
*/ | ||
declare type ExtractorFunction<T = string> = (content: T) => ExtractorResult; | ||
/** | ||
* @public | ||
*/ | ||
declare type ExtractorResult = ExtractorResultDetailed | string[]; | ||
/** | ||
* @public | ||
*/ | ||
declare interface ExtractorResultDetailed { | ||
attributes: { | ||
names: string[]; | ||
values: string[]; | ||
}; | ||
classes: string[]; | ||
ids: string[]; | ||
tags: string[]; | ||
undetermined: string[]; | ||
} | ||
type ExtractorFunction$0<T = string> = (content: T) => string[]; | ||
interface Extractors$0 { | ||
extensions: string[]; | ||
extractor: ExtractorFunction$0; | ||
/** | ||
* @public | ||
*/ | ||
declare interface Extractors { | ||
extensions: string[]; | ||
extractor: ExtractorFunction; | ||
} | ||
interface UserDefinedOptions$0 { | ||
content?: Array<string | RawContent$0>; | ||
contentFunction?: (sourceFile: string) => Array<string | RawContent$0>; | ||
defaultExtractor?: ExtractorFunction$0; | ||
extractors?: Array<Extractors$0>; | ||
fontFace?: boolean; | ||
keyframes?: boolean; | ||
output?: string; | ||
rejected?: boolean; | ||
stdin?: boolean; | ||
stdout?: boolean; | ||
variables?: boolean; | ||
safelist?: UserDefinedSafelist; | ||
blocklist?: StringRegExpArray; | ||
skippedContentGlobs?: Array<string>; | ||
dynamicAttributes?: string[]; | ||
/** | ||
* PostCSS Plugin for PurgeCSS | ||
* | ||
* @param opts - PurgeCSS Options | ||
* @returns the postCSS plugin | ||
* | ||
* @public | ||
*/ | ||
declare const purgeCSSPlugin: postcss.PluginCreator<UserDefinedOptions>; | ||
export default purgeCSSPlugin; | ||
/** | ||
* @public | ||
*/ | ||
declare interface RawContent<T = string> { | ||
extension: string; | ||
raw: T; | ||
} | ||
declare const purgeCSSPlugin: postcss.PluginCreator<UserDefinedOptions$0>; | ||
export { purgeCSSPlugin as default }; | ||
/** | ||
* @public | ||
*/ | ||
declare interface RawCSS { | ||
raw: string; | ||
name?: string; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
declare type StringRegExpArray = Array<RegExp | string>; | ||
/** | ||
* {@inheritDoc purgecss#UserDefinedOptions} | ||
* | ||
* @public | ||
*/ | ||
export declare interface UserDefinedOptions extends Omit<UserDefinedOptions_2, "content" | "css"> { | ||
content?: UserDefinedOptions_2["content"]; | ||
contentFunction?: (sourceFile: string) => Array<string | RawContent>; | ||
} | ||
/** | ||
* Options used by PurgeCSS to remove unused CSS | ||
* | ||
* @public | ||
*/ | ||
declare interface UserDefinedOptions_2 { | ||
/** {@inheritDoc Options.content} */ | ||
content: Array<string | RawContent>; | ||
/** {@inheritDoc Options.css} */ | ||
css: Array<string | RawCSS>; | ||
/** {@inheritDoc Options.defaultExtractor} */ | ||
defaultExtractor?: ExtractorFunction; | ||
/** {@inheritDoc Options.extractors} */ | ||
extractors?: Array<Extractors>; | ||
/** {@inheritDoc Options.fontFace} */ | ||
fontFace?: boolean; | ||
/** {@inheritDoc Options.keyframes} */ | ||
keyframes?: boolean; | ||
/** {@inheritDoc Options.output} */ | ||
output?: string; | ||
/** {@inheritDoc Options.rejected} */ | ||
rejected?: boolean; | ||
/** {@inheritDoc Options.rejectedCss} */ | ||
rejectedCss?: boolean; | ||
/** {@inheritDoc Options.sourceMap } */ | ||
sourceMap?: boolean | (postcss.SourceMapOptions & { to?: string }); | ||
/** {@inheritDoc Options.stdin} */ | ||
stdin?: boolean; | ||
/** {@inheritDoc Options.stdout} */ | ||
stdout?: boolean; | ||
/** {@inheritDoc Options.variables} */ | ||
variables?: boolean; | ||
/** {@inheritDoc Options.safelist} */ | ||
safelist?: UserDefinedSafelist; | ||
/** {@inheritDoc Options.blocklist} */ | ||
blocklist?: StringRegExpArray; | ||
/** {@inheritDoc Options.skippedContentGlobs} */ | ||
skippedContentGlobs?: Array<string>; | ||
/** {@inheritDoc Options.dynamicAttributes} */ | ||
dynamicAttributes?: string[]; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist; | ||
export { } |
@@ -1,1 +0,1 @@ | ||
import e,{defaultOptions as t,standardizeSafelist as s,mergeExtractorSelectors as o}from"purgecss";const r=function(r){if(void 0===r)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(n,c)=>async function(r,n,{result:c}){const i=new e,a={...t,...r,safelist:s(null==r?void 0:r.safelist)};r&&"function"==typeof r.contentFunction&&(a.content=r.contentFunction(n.source&&n.source.input.file||"")),i.options=a;const{content:p,extractors:u}=a,l=p.filter((e=>"string"==typeof e)),f=p.filter((e=>"object"==typeof e)),m=await i.extractSelectorsFromFiles(l,u),g=await i.extractSelectorsFromString(f,u),d=o(m,g);i.walkThroughCSS(n,d),i.options.fontFace&&i.removeUnusedFontFaces(),i.options.keyframes&&i.removeUnusedKeyframes(),i.options.variables&&i.removeUnusedCSSVariables(),i.options.rejected&&i.selectorsRemoved.size>0&&(c.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${i.selectorsRemoved.size} selectors:\n ${Array.from(i.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),i.selectorsRemoved.clear())}(r,n,c)}};r.postcss=!0;export{r as default}; | ||
import*as e from"path";import{PurgeCSS as s,defaultOptions as t,standardizeSafelist as o,mergeExtractorSelectors as r}from"purgecss";const n=function(n){if(void 0===n)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(c,i)=>async function(n,c,{result:i}){const a=new s;let l;try{const s=e.resolve(process.cwd(),"purgecss.config.js");l=await import(s)}catch{}const p={...t,...l,...n,safelist:o((null==n?void 0:n.safelist)||(null==l?void 0:l.safelist))};n&&"function"==typeof n.contentFunction&&(p.content=n.contentFunction(c.source&&c.source.input.file||"")),a.options=p,p.variables&&(a.variablesStructure.safelist=p.safelist.variables||[]);const{content:u,extractors:f}=p,m=u.filter((e=>"string"==typeof e)),g=u.filter((e=>"object"==typeof e)),v=await a.extractSelectorsFromFiles(m,f),d=await a.extractSelectorsFromString(g,f),S=r(v,d);a.walkThroughCSS(c,S),a.options.fontFace&&a.removeUnusedFontFaces(),a.options.keyframes&&a.removeUnusedKeyframes(),a.options.variables&&a.removeUnusedCSSVariables(),a.options.rejected&&a.selectorsRemoved.size>0&&(i.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${a.selectorsRemoved.size} selectors:\n ${Array.from(a.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),a.selectorsRemoved.clear())}(n,c,i)}};n.postcss=!0;export{n as default}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("purgecss");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=t(e);const o=function(t){if(void 0===t)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(o,r)=>async function(t,o,{result:r}){const n=new s.default,c={...e.defaultOptions,...t,safelist:e.standardizeSafelist(null==t?void 0:t.safelist)};t&&"function"==typeof t.contentFunction&&(c.content=t.contentFunction(o.source&&o.source.input.file||"")),n.options=c;const{content:i,extractors:a}=c,u=i.filter((e=>"string"==typeof e)),l=i.filter((e=>"object"==typeof e)),p=await n.extractSelectorsFromFiles(u,a),f=await n.extractSelectorsFromString(l,a),d=e.mergeExtractorSelectors(p,f);n.walkThroughCSS(o,d),n.options.fontFace&&n.removeUnusedFontFaces(),n.options.keyframes&&n.removeUnusedKeyframes(),n.options.variables&&n.removeUnusedCSSVariables(),n.options.rejected&&n.selectorsRemoved.size>0&&(r.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${n.selectorsRemoved.size} selectors:\n ${Array.from(n.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),n.selectorsRemoved.clear())}(t,o,r)}};o.postcss=!0,module.exports=o; | ||
"use strict";var e=require("path"),t=require("purgecss");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=r(e);const o=function(e){if(void 0===e)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(o,n)=>async function(e,o,{result:n}){const c=new t.PurgeCSS;let i;try{const e=s.resolve(process.cwd(),"purgecss.config.js");i=await function(e){return Promise.resolve().then((function(){return r(require(e))}))}(e)}catch{}const a={...t.defaultOptions,...i,...e,safelist:t.standardizeSafelist((null==e?void 0:e.safelist)||(null==i?void 0:i.safelist))};e&&"function"==typeof e.contentFunction&&(a.content=e.contentFunction(o.source&&o.source.input.file||"")),c.options=a,a.variables&&(c.variablesStructure.safelist=a.safelist.variables||[]);const{content:u,extractors:l}=a,f=u.filter((e=>"string"==typeof e)),p=u.filter((e=>"object"==typeof e)),d=await c.extractSelectorsFromFiles(f,l),g=await c.extractSelectorsFromString(p,l),v=t.mergeExtractorSelectors(d,g);c.walkThroughCSS(o,v),c.options.fontFace&&c.removeUnusedFontFaces(),c.options.keyframes&&c.removeUnusedKeyframes(),c.options.variables&&c.removeUnusedCSSVariables(),c.options.rejected&&c.selectorsRemoved.size>0&&(n.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${c.selectorsRemoved.size} selectors:\n ${Array.from(c.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),c.selectorsRemoved.clear())}(e,o,n)}};o.postcss=!0,module.exports=o; |
{ | ||
"name": "@fullhuman/postcss-purgecss", | ||
"version": "4.1.3", | ||
"version": "5.0.0", | ||
"description": "PostCSS plugin for PurgeCSS", | ||
@@ -23,3 +23,4 @@ "author": "FoundrySH <no-reply@foundry.sh>", | ||
"scripts": { | ||
"test": "echo \"Error: run tests from root\" && exit 1" | ||
"build": "ts-node build.ts", | ||
"test": "jest" | ||
}, | ||
@@ -30,6 +31,6 @@ "bugs": { | ||
"dependencies": { | ||
"purgecss": "^4.1.3" | ||
"purgecss": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.3.0" | ||
"postcss": "^8.4.4" | ||
}, | ||
@@ -42,4 +43,3 @@ "peerDependencies": { | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"gitHead": "37e5053a446880d12fd2f55abfc362c3dac9c49c" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12393
163
5
1
1
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedcommander@9.5.0(transitive)
+ Addedglob@8.1.0(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedpurgecss@5.0.0(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcommander@8.3.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedglob@7.2.3(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpurgecss@4.1.3(transitive)
Updatedpurgecss@^5.0.0