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

@fullhuman/postcss-purgecss

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fullhuman/postcss-purgecss - npm Package Compare versions

Comparing version 1.3.0 to 2.0.3

lib/postcss-purgecss.d.ts

105

lib/postcss-purgecss.js

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

'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var path = _interopDefault(require('path'));
var postcss = _interopDefault(require('postcss'));
var Purgecss = _interopDefault(require('purgecss'));
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var CONFIG_FILENAME = 'purgecss.config.js';
var ERROR_CONFIG_FILE_LOADING = 'Error loading the config file';
var loadConfigFile = function loadConfigFile(configFile) {
var pathConfig = typeof configFile === 'undefined' ? CONFIG_FILENAME : configFile;
var options;
try {
var t = path.resolve(process.cwd(), pathConfig);
options = require(t);
} catch (e) {
throw new Error(ERROR_CONFIG_FILE_LOADING + e.message);
}
return options;
};
var index = postcss.plugin('postcss-plugin-purgecss', function (opts) {
return function (root, result) {
if (typeof opts === 'string' || typeof opts === 'undefined') opts = loadConfigFile(opts);
if (!opts.css || !opts.css.length) {
opts.css = ['__postcss_purgecss_placeholder'];
}
var purgecss = new Purgecss(opts);
purgecss.root = root; // Get selectors from content files
var _purgecss$options = purgecss.options,
content = _purgecss$options.content,
extractors = _purgecss$options.extractors;
var fileFormatContents = content.filter(function (o) {
return typeof o === 'string';
});
var rawFormatContents = content.filter(function (o) {
return _typeof(o) === 'object';
});
var cssFileSelectors = purgecss.extractFileSelector(fileFormatContents, extractors);
var cssRawSelectors = purgecss.extractRawSelector(rawFormatContents, extractors); // Get css selectors and remove unused ones
var cssSelectors = new Set([].concat(_toConsumableArray(cssFileSelectors), _toConsumableArray(cssRawSelectors))); // purge selectors
purgecss.getSelectorsCss(cssSelectors); // purge keyframes
if (purgecss.options.keyframes) purgecss.removeUnusedKeyframes(); // purge font face
if (purgecss.options.fontFace) purgecss.removeUnusedFontFaces();
if (purgecss.options.rejected && purgecss.selectorsRemoved.size > 0) {
result.messages.push({
type: 'purgecss',
plugin: 'postcss-purgecss',
text: "purging ".concat(purgecss.selectorsRemoved.size, " selectors:\n ").concat(Array.from(purgecss.selectorsRemoved).map(function (selector) {
return selector.trim();
}).join('\n '))
});
purgecss.selectorsRemoved.clear();
}
};
});
module.exports = index;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var postcss=_interopDefault(require("postcss")),PurgeCSS=require("purgecss"),PurgeCSS__default=_interopDefault(PurgeCSS);const purgeCSSPlugin=postcss.plugin("postcss-plugin-purgecss",(function(e){return async function(t,s){const r=new PurgeCSS__default,o={...PurgeCSS.defaultOptions,...e};r.options=o;const{content:n,extractors:u}=o,c=n.filter(e=>"string"==typeof e),i=n.filter(e=>"object"==typeof e),p=await r.extractSelectorsFromFiles(c,u),a=r.extractSelectorsFromString(i,u),l=PurgeCSS.mergeExtractorSelectors(p,a);r.walkThroughCSS(t,l),r.options.fontFace&&r.removeUnusedFontFaces(),r.options.keyframes&&r.removeUnusedKeyframes(),r.options.variables&&r.removeUnusedCSSVariables(),r.options.rejected&&r.selectorsRemoved.size>0&&(s.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${r.selectorsRemoved.size} selectors:\n ${Array.from(r.selectorsRemoved).map(e=>e.trim()).join("\n ")}`}),r.selectorsRemoved.clear())}}));module.exports=purgeCSSPlugin;
{
"name": "@fullhuman/postcss-purgecss",
"version": "1.3.0",
"version": "2.0.3",
"description": "PostCSS plugin for PurgeCSS",
"main": "./lib/postcss-purgecss.js",
"module": "./lib/postcss-purgecss.es.js",
"jsnext:main": "./lib/postcss-purgecss.es.js",
"author": "FoundrySH <no-reply@foundry.sh>",
"homepage": "https://github.com/FullHuman/purgecss#readme",
"license": "MIT",
"main": "lib/postcss-purgecss.js",
"module": "lib/postcss-purgecss.esm.js",
"types": "lib/postcss-purgecss.d.ts",
"directories": {
"lib": "lib",
"test": "__tests__",
"example": "examples"
"test": "__tests__"
},
"keywords": [
"postcss",
"postcss-plugin",
"remove",
"unused",
"css",
"purgecss"
"files": [
"lib"
],
"author": "FoundrySH <no-reply@foundry.sh>",
"license": "MIT",
"repository": "FullHuman/postcss-purgecss",
"repository": {
"type": "git",
"url": "git+https://github.com/FullHuman/purgecss.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
"url": "https://github.com/FullHuman/postcss-purgecss/issues"
"url": "https://github.com/FullHuman/purgecss/issues"
},
"homepage": "https://github.com/FullHuman/postcss-purgecss",
"dependencies": {
"postcss": "^7.0.14",
"purgecss": "^1.4.0"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.6.0",
"@babel/preset-flow": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.0",
"codacy-coverage": "^3.4.0",
"eslint": "^6.3.0",
"eslint-plugin-flowtype": "^4.3.0",
"flow-bin": "^0.107.0",
"jest": "^24.9.0",
"prettier": "^1.18.0",
"rollup": "^1.21.2",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-flow": "^1.1.1",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^5.2.0"
},
"scripts": {
"test": "npx jest __tests__/.+.test.js",
"dev": "rollup -c rollup.config.js -w",
"build": "rollup -c rollup.config.js",
"lint": "npx eslint -c .eslintrc src/",
"flow": "npx flow",
"prettier": "npx prettier --write --write --tab-width 4 --no-semi --single-quote '{src,__{tests,mocks}__}/**/*.js'"
"postcss": "7.0.26",
"purgecss": "^2.0.3"
}
}
# PostCSS Purgecss
[![Build Status](https://travis-ci.org/FullHuman/postcss-purgecss.svg?branch=master)](https://travis-ci.org/FullHuman/postcss-purgecss)
[![CircleCi](https://circleci.com/gh/FullHuman/postcss-purgecss/tree/master.svg?style=shield)]()
[![dependencies Status](https://david-dm.org/fullhuman/postcss-purgecss/status.svg)](https://david-dm.org/fullhuman/postcss-purgecss)
[![devDependencies Status](https://david-dm.org/fullhuman/postcss-purgecss/dev-status.svg)](https://david-dm.org/fullhuman/postcss-purgecss?type=dev)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2554f9858cb742ed93eb22f49ccec3c3)](https://www.codacy.com/app/FullHuman/postcss-purgecss?utm_source=github.com&utm_medium=referral&utm_content=FullHuman/postcss-purgecss&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/2554f9858cb742ed93eb22f49ccec3c3)](https://www.codacy.com/app/FullHuman/postcss-purgecss?utm_source=github.com&utm_medium=referral&utm_content=FullHuman/postcss-purgecss&utm_campaign=Badge_Coverage)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![npm](https://img.shields.io/npm/v/postcss-purgecss.svg)](https://www.npmjs.com/package/@fullhuman/postcss-purgecss)
[![license](https://img.shields.io/github/license/fullhuman/postcss-purgecss.svg)]() [![Greenkeeper badge](https://badges.greenkeeper.io/FullHuman/postcss-purgecss.svg)](https://greenkeeper.io/)
![David (path)](https://img.shields.io/david/FullHuman/purgecss?path=packages%2Fpostcss-purgecss&style=for-the-badge)
![Dependabot](https://img.shields.io/badge/dependabot-enabled-%23024ea4?style=for-the-badge)
![npm](https://img.shields.io/npm/v/@fullhuman/postcss-purgecss?style=for-the-badge)
![npm](https://img.shields.io/npm/dw/@fullhuman/postcss-purgecss?style=for-the-badge)
![GitHub](https://img.shields.io/github/license/FullHuman/purgecss?style=for-the-badge)

@@ -83,3 +79,3 @@ [PostCSS] plugin for PurgeCSS.

Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of
Please read [CONTRIBUTING.md](./../../CONTRIBUTING.md) for details on our code of
conduct, and the process for submitting pull requests to us.

@@ -93,3 +89,3 @@

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
This project is licensed under the MIT License - see the [LICENSE](./../../LICENSE) file
for details.
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