init
This commit is contained in:
164
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.d.ts
generated
vendored
Normal file
164
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.d.ts
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* @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[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
declare interface Extractors {
|
||||
extensions: string[];
|
||||
extractor: ExtractorFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.esm.js
generated
vendored
Normal file
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.esm.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
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
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.js
generated
vendored
Normal file
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"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;
|
||||
Reference in New Issue
Block a user