Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-purgecss

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-purgecss - npm Package Compare versions

Comparing version 4.1.3 to 5.0.0

203

lib/gulp-purgecss.d.ts

@@ -1,61 +0,154 @@

import internal from "stream";
interface RawContent<T = string> {
extension: string;
raw: T;
/// <reference types="node" />
import * as internal from 'stream';
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[];
}
interface RawCSS {
raw: string;
name?: string;
/**
* @public
*/
declare interface Extractors {
extensions: string[];
extractor: ExtractorFunction;
}
interface ExtractorResultDetailed {
attributes: {
names: string[];
values: string[];
};
classes: string[];
ids: string[];
tags: string[];
undetermined: string[];
/**
*
* @param options - options
* @returns
*
* @public
*/
declare function gulpPurgeCSS(options: UserDefinedOptions): internal.Transform;
export default gulpPurgeCSS;
/**
* @public
*/
declare interface RawContent<T = string> {
extension: string;
raw: T;
}
type ExtractorResult = ExtractorResultDetailed | string[];
type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
interface Extractors {
extensions: string[];
extractor: ExtractorFunction;
/**
* @public
*/
declare interface RawCSS {
raw: string;
name?: string;
}
type StringRegExpArray = Array<RegExp | string>;
type ComplexSafelist = {
standard?: StringRegExpArray;
deep?: RegExp[];
greedy?: RegExp[];
variables?: StringRegExpArray;
keyframes?: StringRegExpArray;
};
type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
interface UserDefinedOptions {
content: Array<string | RawContent>;
css: Array<string | RawCSS>;
defaultExtractor?: ExtractorFunction;
extractors?: Array<Extractors>;
fontFace?: boolean;
keyframes?: boolean;
output?: string;
rejected?: boolean;
rejectedCss?: boolean;
stdin?: boolean;
stdout?: boolean;
variables?: boolean;
safelist?: UserDefinedSafelist;
blocklist?: StringRegExpArray;
skippedContentGlobs?: Array<string>;
dynamicAttributes?: string[];
/**
* @public
*/
declare type StringRegExpArray = Array<RegExp | string>;
/**
* @public
*/
export declare interface UserDefinedOptions extends Omit<UserDefinedOptions_2, "css" | "content"> {
content: string[];
}
type PurgeCSSUserDefinedOptions = UserDefinedOptions;
interface UserDefinedOptions$0
extends Omit<PurgeCSSUserDefinedOptions, "css" | "content"> {
content: string[];
/**
* 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[];
}
declare function gulpPurgeCSS(
options: UserDefinedOptions$0
): internal.Transform;
export { gulpPurgeCSS as default };
/**
* @public
*/
declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
export { }

@@ -1,1 +0,1 @@

import e from"glob";import t from"plugin-error";import r from"purgecss";import n from"through2";function o(o){return n.obj((async function(s,c,i){if(s.isNull())return i(null,s);if(s.isBuffer())try{const t={...o,content:(u=o.content,u.reduce(((t,r)=>[...t,...e.sync(r)]),[])),css:[{raw:s.contents.toString()}],stdin:!0},n=(await(new r).purge(t))[0],c=t.rejected&&n.rejected?n.rejected.join(" {}\n")+" {}":n.css;s.contents=Buffer.from(c,"utf-8"),i(null,s)}catch(e){e instanceof Error&&this.emit("error",new t("gulp-purgecss",e.message))}var u;if(s.isStream()){let e="";s.contents.on("data",(t=>{e+=t.toString()})).on("end",(async()=>{try{const t={...o,css:[{raw:e}]},c=(await(new r).purge(t))[0],u=t.rejected&&c.rejected?c.rejected.join(" {}\n")+" {}":c.css,f=n();f.write(Buffer.from(u,"utf-8")),s.contents=s.contents.pipe(f),i(null,s)}catch(e){e instanceof Error&&this.emit("error",new t("gulp-purgecss",e.message))}}))}}))}export{o as default};
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};

@@ -1,1 +0,1 @@

"use strict";var e=require("glob"),t=require("plugin-error"),r=require("purgecss"),n=require("through2");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=u(e),c=u(t),o=u(r),i=u(n);module.exports=function(e){return i.default.obj((async function(t,r,n){if(t.isNull())return n(null,t);if(t.isBuffer())try{const r={...e,content:(u=e.content,u.reduce(((e,t)=>[...e,...s.default.sync(t)]),[])),css:[{raw:t.contents.toString()}],stdin:!0},c=(await(new o.default).purge(r))[0],i=r.rejected&&c.rejected?c.rejected.join(" {}\n")+" {}":c.css;t.contents=Buffer.from(i,"utf-8"),n(null,t)}catch(e){e instanceof Error&&this.emit("error",new c.default("gulp-purgecss",e.message))}var u;if(t.isStream()){let r="";t.contents.on("data",(e=>{r+=e.toString()})).on("end",(async()=>{try{const u={...e,css:[{raw:r}]},s=(await(new o.default).purge(u))[0],c=u.rejected&&s.rejected?s.rejected.join(" {}\n")+" {}":s.css,a=i.default();a.write(Buffer.from(c,"utf-8")),t.contents=t.contents.pipe(a),n(null,t)}catch(e){e instanceof Error&&this.emit("error",new c.default("gulp-purgecss",e.message))}}))}}))};
"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))}}))}}))};
{
"name": "gulp-purgecss",
"version": "4.1.3",
"version": "5.0.0",
"description": "Gulp plugin for purgecss",

@@ -35,8 +35,9 @@ "author": "Ffloriel",

"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
"build": "ts-node build.ts",
"test": "jest"
},
"dependencies": {
"glob": "^7.1.6",
"plugin-error": "^1.0.1",
"purgecss": "^4.1.3",
"glob": "^8.0.3",
"plugin-error": "^2.0.0",
"purgecss": "^5.0.0",
"through2": "^4.0.1"

@@ -46,6 +47,8 @@ },

"@types/event-stream": "^4.0.0",
"@types/glob": "^7.2.0",
"@types/through2": "^2.0.34",
"@types/vinyl": "^2.0.4",
"event-stream": "^4.0.1",
"vinyl": "^2.2.0"
"vinyl": "^2.2.0",
"vinyl-sourcemaps-apply": "^0.2.1"
},

@@ -58,4 +61,3 @@ "bugs": {

"registry": "https://registry.npmjs.org/"
},
"gitHead": "37e5053a446880d12fd2f55abfc362c3dac9c49c"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc