@fullhuman/postcss-purgecss
Advanced tools
Comparing version 1.3.0 to 2.0.3
@@ -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. |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
0
7697
6
71
1
90
1
+ Addedchalk@2.4.2(transitive)
+ Addedcommander@5.1.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedpostcss@7.0.267.0.32(transitive)
+ Addedpurgecss@2.3.0(transitive)
+ Addedsupports-color@5.5.06.1.0(transitive)
- Removedansi-regex@4.1.1(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcliui@5.0.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removedemoji-regex@7.0.3(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedget-caller-file@2.0.5(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedpurgecss@1.4.2(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedstring-width@3.1.0(transitive)
- Removedstrip-ansi@5.2.0(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@5.1.0(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyargs@14.2.3(transitive)
- Removedyargs-parser@15.0.3(transitive)
Updatedpostcss@7.0.26
Updatedpurgecss@^2.0.3