Git Product home page Git Product logo

rbtech / css-purge Goto Github PK

View Code? Open in Web Editor NEW
124.0 4.0 19.0 1.87 MB

A CSS tool written in Node JS as a command line app or library for the purging, burning, reducing, shortening, compressing, cleaning, trimming and formatting of duplicate, extra, excess or bloated CSS.

Home Page: http://rbtech.github.io/css-purge

License: MIT License

JavaScript 83.16% HTML 14.36% CSS 2.48%
css-purge css cssmin cssminifier cssminify duplicate-css-rules nodejs unusedcss

css-purge's Introduction

npm npm NpmLicense

V3 - We just released our most awesome version yet!

A CSS tool written in Node JS as a command line app or library for the purging, burning, reducing, shortening, compressing, cleaning, trimming and formatting of duplicate, extra, excess or bloated CSS.

CSS Purge

Overview

Purging CSS

This is the typical usage scenario, where you may want to purge some CSS from a file(s) or folder(s) or CSS from your workflow (like from gulp or grunt).

Purging CSS

Purging Unused CSS

You want to take it a step further by taking your CSS file(s) and reducing it further based on what is used in your HTML file(s).

Purging Unused CSS

Usage

CLI App Usage

Global usage is nice for doing something quick everywhere.

  1. Install with npm:
npm install css-purge -g
  1. Run with options:
css-purge [CLI options]

CLI Options:

Command Description
-i "filename/folder name location" CSS file(s) input
-o "filename" The new CSS filename to output as
-c "some CSS" input CSS from CLI
-f "config filename" run with a custom config filename
-m "filename/folder name/URL location" HTML file(s) input
-d run with the default config file (config_css.json must exist in folder)
-v displays the version number
-h CLI help
Examples

CSS - Purge some CSS and output to terminal

css-purge -c ".panel { color:red; color: blue; }"

CSS file - Purge CSS from main.css and output to main.min.css

css-purge -i main.css -o main.min.css

CSS file with Custom Config - Purge CSS from main.css and output to main.min.css using myconfig.json for configuration

css-purge -i main.css -o main.min.css -f myconfig.json

CSS file with HTML file - Purge CSS from main.css using index.html to compare and output to main.min.css

css-purge -i main.css -o main.min.css -m index.html

Multiple CSS and HTML files - Purge CSS from main.css and framework.css (in that specific order) using index.html and index.html from www.mywebsite.com to compare and output to main.min.css

css-purge -i "main.css, framework.css" -o main.min.css -m "index.html, http://www.mywebsite.com/index.html"

Project Usage

Local usage is nice for “setting up shop” for a project.

  1. Clone with git/GitHub Desktop:
git clone https://github.com/rbtech/css-purge.git

or download from: https://github.com/rbtech/css-purge

  1. Install dependencies:
npm install
  1. Run with options
node css-purge [CLI options]

CLI Options:

Command Description
-i "filename/folder name location" CSS file(s) input
-o "filename" The new CSS filename to output as
-c "some CSS" input CSS from CLI
-f "config filename" run with a custom config filename
-m "filename/folder name/URL location" HTML file(s) input
-d run with the default config file (config_css.json must exist in folder)
-v displays the version number
-h CLI help

Node JS Library Usage

Libraries help share the awesomeness to more people :)

You can test out the library in your browser here.

Install:

npm install css-purge --save

Some example usage:

 var cssPurge = require('css-purge');
  
  //purging a CSS string with options
  var css = "p { color: blue; color: blue; } ";

  cssPurge.purgeCSS(css, {
    trim : true,
    shorten : true
  }, function(error, result){
    if (error)
      console.log(error)
    else
      console.log('Output CSS: ',  result);
  });


  //uses default settings that are set in the config file
  //make sure that css is set
  cssPurge.purgeCSSFiles();
  
  //purging a CSS file
  cssPurge.purgeCSSFiles({ 
    css:'demo/test1.css' 
  });
  
  //purging a CSS file with HTML
  cssPurge.purgeCSSFiles({
    css: 'demo/test1.css', 
    html: 'demo/html/test1.html'
  });
  
  //purging a CSS file with HTML and options
  cssPurge.purgeCSSFiles({
    css_output: 'test1.min.css',
    css: 'demo/test1.css', 
    html: 'demo/html/test1.html',
    trim : true,
    shorten : true,
    verbose : true
  });
  
  //purging a CSS file with HTML, options and config
  cssPurge.purgeCSSFiles({
      css_output: 'test1.min.css',
      css: 'demo/test1.css', 
      html: 'demo/html/test1.html',
      trim : true,
      shorten : true,
      verbose : true
    },
    'myconfig.json'
  );

CSS-Purge Report Viewer

Report Preview

Open a separate terminal window, then:

  1. Clone with git/GitHub Desktop:
git clone https://github.com/rbtech/css-purge-report-viewer.git

or download from: https://github.com/rbtech/css-purge-report-viewer

  1. Install reload:
npm install reload -g
  1. Run reload to view the report:
reload -b -e html, css, js, json

Report notes:

  • make sure you are in the report viewers directory before running reload
  • make sure CSS-Purge is set to generate into the report viewers directory

Config Options

For an overview of some of the options/features, have a look Under the hood.

Full description of each option can be found on the website (Getting Started > Config).

Example config.json:

{
  "options": {
    "css_output": "purged.min.css",
    "css": "demo/html/static-jekyll/_siteassets/main.css",
    
    "html": "demo/html/static-jekyll/_site",
    
    "new_reduce_common_into_parent": true,
    
    "trim": true,
    "trim_keep_non_standard_inline_comments": false,
    "trim_removed_rules_previous_comment": true,
    "trim_comments": false,
    "trim_whitespace": false,
    "trim_breaklines": false,
    "trim_last_semicolon": false,
    
    "shorten": true,
    "shorten_zero": false,
    "shorten_hexcolor": false,
    "shorten_hexcolor_extended_names": false,
    "shorten_hexcolor_UPPERCASE": false,
    "shorten_font": false,
    "shorten_background": true,
    "shorten_background_min": 2,
    "shorten_margin": false,
    "shorten_padding": false,
    "shorten_list_style": false,
    "shorten_outline": false,
    "shorten_border": false,
    "shorten_border_top": false,
    "shorten_border_right": false,
    "shorten_border_bottom": false,
    "shorten_border_left": false,
    "shorten_border_radius": false,
    
    "format": true,
    "format_4095_rules_legacy_limit": false,
    "format_font_family": true,
    
    "special_convert_rem": false,
    "special_convert_rem_browser_default_px": "16",
    "special_convert_rem_desired_html_px": "10",
    "special_convert_rem_font_size": true,
    
    "special_reduce_with_html" : false,
    "special_reduce_with_html_ignore_selectors" : [
      "@-ms-",
      ":-ms-",
      "::",
      ":valid",
      ":invalid",
      "+.",
      ":-"
    ],
    
    "generate_report": true,
    "verbose": true,
    
    "bypass_media_rules": true,
    "bypass_document_rules": false,
    "bypass_supports_rules": false,
    "bypass_page_rules": false,
    "bypass_charset": false,
    
    "zero_units": "em, ex, %, px, cm, mm, in, pt, pc, ch, rem, vh, vw, vmin, vmax",
    "zero_ignore_declaration": [],
    
    "report_file_location": "report/purged_css_report_data.json",
    
    "reduce_declarations_file_location": "config_reduce_declarations.json"
  }
}

Plugins!

We will list them as they come.

Help

Source Code Issues
Community and Q&A

Got a question on how to do something and when answered will help everyone? Then place it on StackOverflow with the tag “css-purge”

License

(The MIT License)

Copyright (c) 2017 Red Blueprint Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

css-purge's People

Contributors

andreweq avatar dependabot[bot] avatar ronnyvv avatar rw355 avatar tomscholz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

css-purge's Issues

After purge, all the hover styles are removed.

.toppest-right .iconfont {
  font-size: 1.4rem;
}
.toppest-right a:hover {
  text-decoration: none;
  color: #23a4db;
}
#topHeader {
  background: #08a1e5 url("../img/top-header.jpg") top no-repeat;
}

After css-purge

.toppest-right .iconfont {
  font-size: 1.4rem;
}
#topHeader {
  background: #08a1e5 url("../img/top-header.jpg") top no-repeat;
}

css-purge always minifies, no matter which trim option is enabled

I tried all combinations of the trim options, no matter what I do, the resulting file is always minified - I do not want that to happen, as I still would like to edit the resulting files sometimes, but the options that look like should be used to disable that (trimming of whitespace and newline chars) do not seem to work at all.

Output includes unwanted selectors

This tool is great! I am using it with Gulp. I have a very small HTML file that I am running the purge against. There is no <a> element in it. However the output includes CSS with the a selector. Upon troubleshooting, I found this happens when there is the word "a" inside of a div tag. Just plain text, like "I pet a small dog". The tool see the word "a" and thinks it is an element and outputs CSS with the selector "a". Likewise for the word "small", etc. I am hoping this is an easy fix?

Empty Rules With Border-Radius And Calc Function

I noticed that this tool fails in some cases when a calc() function is passed as a parameter to border-radius.

For example,
.class {
border-radius: 0 0 calc(0.25rem - 1px) calc(0.25rem - 1px);
}

Becomes:
.class {
border-radius: ;
}

Is this a known issue?

not working on Windows 10

$ node css-purse -i plugins/Social/webroot/css/nav.css -o plugins/Social/webroot/css/na1v.css
module.js:471
throw err;
^
Error: Cannot find module 'E:\webapp\css-purse'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3

!important rules are mis-prioritized

That's the input CSS:
.class{ border-right: 0 !important; border-right: 100000000px; }

That's the output:
.class{border-right:100000000px}

How to resolve this? I have a HUUUUUGE CSS file with many of !important statements.

@font-face not handled correctly

Hi,

I found a bug:

All @font-face are joint together in one big @font-face. This is not correct, because only the last font-style survives.

Input-Example:

@font-face {
  font-family: "AppFontSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateARegularItalic/corporatea-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateARegularItalic/corporatea-regita-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: normal;
  font-weight: bold;
  src: url("../fonts/corporateABold/corporab-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateABold/corporab-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateADemiItalic/corpoademitalic-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemiItalic/corpoademitalic-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/corporateADemi/corpoadem-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemi/corpoadem-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/corporateSRegular/corporsr-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegular/corporsr-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateSLightItalic/corposli-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSLightItalic/corposli-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: normal;
  font-weight: bold;
  src: url("../fonts/corporateSBold/corporatesbold-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSBold/corporatesbold-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateSRegularItalic/corposregital-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegularItalic/corposregital-webfont.ttf") format("truetype");
}

Output Example:

@font-face {
    font-family: "AppFontSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: normal;
    font-weight: normal;
    src: url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateARegularItalic/corporatea-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateARegularItalic/corporatea-regita-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: normal;
    font-weight: bold;
    src: url("../fonts/corporateABold/corporab-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateABold/corporab-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateADemiItalic/corpoademitalic-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemiItalic/corpoademitalic-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: normal;
    font-weight: normal;
    src: url("../fonts/corporateADemi/corpoadem-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemi/corpoadem-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: normal;
    font-weight: normal;
    src: url("../fonts/corporateSRegular/corporsr-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegular/corporsr-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateSLightItalic/corposli-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSLightItalic/corposli-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: normal;
    font-weight: bold;
    src: url("../fonts/corporateSBold/corporatesbold-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSBold/corporatesbold-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateSRegularItalic/corposregital-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegularItalic/corposregital-webfont.ttf") format("truetype");
}

Getting /_3token_hck_ error in purged css files

After purging css file I am getting this error in multiple lines:
/_3token_hck_1:/
/_3token_hck_2:
/
/_3token_hck_3:*/
and so on ...

I think you have misspelled the comment line and used an underscore instead of asterisk.

the demo doesn't work

I tryd the demo
https://github.com/rbtech/css-purge/blob/master/demo/css-purge-demo-app.js

a Comma is missing after "shorten : true".
Fixing that, the console logs

Output CSS:  p{color:#00f}
Config File read error: Something went wrong while reading the file, check your config_css.json and please try again.
{ Error: ENOENT: no such file or directory, open 'c:\projectplace\config_css.json'
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'c:\\projectplace\\config_css.json' }

The output is show for the purgeCSS example as well as for the purgeCSSFiles example.
The config_css.json is located in /projectroot/node_modules/css-purge/ but got searched in /projectroot/

I've used [email protected]

SyntaxError: Unexpected end of JSON input

I am getting this error and the JSON seems valid:

$ css-purge -f config3.json -v
undefined:1



[SyntaxError: Unexpected end of JSON input](url)
    at JSON.parse (<anonymous>)
    at ReadStream.<anonymous> (/usr/lib/node_modules/css-purge/lib/css-purge.js:1627:23)
    at ReadStream.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

This is config.json file (renamed to txt so github allow the upload)
config3.txt

bug: removing used code

Hi, I have 2 files with the same styles

//1.css and 2.css same content

#breadcrumb ul {
  list-style: none;
  margin: 8px 0 0 0 !important;
  padding: 0 !important;
}

#breadcrumb li {
  float: left;
  margin-left: 0;
  padding-left: 0;
}

// config_css.json

{
  "options": {
    "trim": false,
    "shorten": false,
    "format": false
  }
}

when I run this: css-purge -i "1.css,2.css" -o 3.css -f config_css.json I get this weird result:

image

And the list-style: none; just disappeared :(

Is this a bug? any idea why? basically I have 2 big very similar css files and I want to remove duplicate styles

Thanks in advance!

bug: the line that's after one with "important" is missed

Hello. I want to remove duplicate declarations in my css. Some of them contain rules with and without "important".

I've tried simple example but found the following behaviour (everything is set to false in the config)

Input:

body {
    padding: 5px !important;
    margin: 5px;
    font-size: 15px;
}

body {
    padding: 10px;
}

Output:

body {
  padding: 5px !important;
  font-size: 15px;
  padding: 10px;
}

The margin is missed.


Input:

body {
    padding: 5px;
    margin: 5px;
    font-size: 15px;
}

body {
    padding: 10px;
}

Output:

body {
  margin: 5px;
  font-size: 15px;
  padding: 10px;
}

Everything is ok.

What's the problem? Am I doing something wrong?

Webpack Loader

Hi,

Thanks for creating this awesome tool.

Is there any chance of a webpack loader?

Output multiple blank lines

If the input file has successive/multiple blank lines, output the same number of .blank lines.

To make file comparison easier!

DOMException [SyntaxError]: 'undefined' is not a valid selector

When running css purge I was using the following:

css-purge -i "assets/styles/theme-ph.css, assets/styles/webmail.css, assets/styles/skin.css, assets/styles/jquery-ui.css " -o main.min.css -m "index.html, wordpress/index.html, website-builder/index.html, terms-and-conditions/index.html, vps/index.html, privacy-policy/index.html, new-page.html, managed-vps/index.html, hosting/index.html, login/index.html, gdpr/index.html, faqs/index.html, domain/index.html, contact/index.html, certificates/index.html, cdn/index.html, about/index.html, affiliates/index.html, free-hosting/index.html, services/index.html, legal/index.html, legal/complaints/index.html"

it spat out this error:

C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:567
        throw err;
        ^
DOMException [SyntaxError]: 'undefined' is not a valid selector
    at emit (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:565:17)
    at compileSelector (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:1305:11)
    at compileSelector (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:1033:30)
    at compile (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:753:16)
    at collect (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:1553:24)
    at _querySelectorAll (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:1518:36)
    at Object._querySelector [as first] (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\nwsapi\src\nwsapi.js:1424:14)
    at DocumentImpl.<anonymous> (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\jsdom\lib\jsdom\living\nodes\ParentNode-impl.js:65:42)
    at DocumentImpl.querySelector (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\jsdom\lib\jsdom\utils.js:123:45)
    at Document.querySelector (C:\Users\rchow\AppData\Roaming\npm\node_modules\css-purge\node_modules\jsdom\lib\jsdom\living\generated\Document.js:689:45)

Going to the file listed here is the code

  // centralized error and exceptions handling
  emit =
    function(message, proto) {
      var err;
      if (Config.VERBOSITY) {
        if (proto) {
          err = new proto(message);
        } else {
          err = new global.DOMException(message, 'SyntaxError');
        }
        throw err;
      }
      if (Config.LOGERRORS && console && console.log) {
        console.log(message);
      }
    },

Is there an ES6 Modules (ESM) version of CSS Purge

I'm attempting to use GraalVM Polyglot JavaScript to execute a CSS Purge. GraalVM doesn't support node 'require' (out the box - seems there may be some magic config that I have not yet discovered). Only ES6 style imports. Is there an ESM version of css-purge?

CSS Hack - *crossed*

Hello, I've updated my css-purge to latest 3.0.4 and noticing following problems:

Original CSS:
border: 0.2em solid #F0F2FA;

Purged CSS:
border: 0 solid #F0F2FA;

Original CSS:

background-color: #FFF;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
margin-bottom: 20px;
padding: 20px;
clear: both; *crossed*
overflow: hidden; *crossed*
background-color: #04003F;
position: relative;
text-decoration: none;
position: relative;
padding-bottom: 60px;
overflow: hidden;
clear: none;

Purged CSS:

border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
margin-bottom: 20px;
padding: 20px 20px 60px;
clear: both;
overflow: hidden;
background-color: #04003F;
position: relative;
text-decoration: none;
overflow: hidden;

So there are 2 problems:

  1. "border" styles with 0.2em getting cut off to 0
  2. Cleaning dup of "clear" being decided wrong

Any workaround on this?

display: flex property issue

input test file:

`
.footer {
padding: 50px 0;
background: #d6d6d6;
}

.footer__navigation ul {
list-style-type: none;
padding: 0;
margin: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin: 0 -15px;
}

.footer__navigation li {
padding: 0 15px;
}

.navigation__main>nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin: 10px -15px 0;
}

.footer {
padding: 50px 0;
background: #d6d6d6;
}

.footer__navigation ul {
list-style-type: none;
padding: 0;
margin: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin: 0 -15px;
}

.footer__navigation li {
padding: 0 15px;
}

.navigation__main>nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin: 10px -15px 0;
}
`

Output:

.footer{padding:50px 0;background:#d6d6d6}.footer__navigation ul{display:-webkit-box;flex-wrap:wrap;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.footer__navigation li{padding:0 15px}.navigation__main>nav{display:-ms-flexbox;display:-ms-flexbox;display:flex;margin:10px -15px 0}

You see there are missing properties, for example:

.footer__navigation ul > list-style-type: none;

Remove node_modules

The node_modules folder is not required to be in the repository. Dependencies could installed after checkout via npm install if they are referenced in the package.json.

Wrong styles removed

Tested with css-purge cli

Input:

#red {
    color: red;
}

.colors #blue {
    color: green;
}

.colors #blue {
    color: blue;
}

#red {
    color: red
}

.colors #blue {
    color: green
}

Output:

#red {
    color: red
}

.colors #blue {
    color: #00f //blue
}

Shoud be:

#red {
    color: red
}

.colors #blue {
    color: green
}

@media queries not retain

Using the example config, how do you retain CSS with @media ... which is being strip away after CSS purge.

For responsive CSS, if I have mb2 classes in global scope and the same classes name is in @media... scope, now do you retain 2 duplicates classes for responsive website?

{
  "options": {
    "css_output": "purged.min.css",
    "css": "dist/r.css",
    
    "html": "dist",
    
    "trim": true,
    "trim_keep_non_standard_inline_comments": false,
    "trim_removed_rules_previous_comment": true,
    "trim_comments": false,
    "trim_whitespace": false,
    "trim_breaklines": false,
    "trim_last_semicolon": false,
    
    "shorten": true,
    "shorten_zero": false,
    "shorten_hexcolor": false,
    "shorten_hexcolor_extended_names": false,
    "shorten_hexcolor_UPPERCASE": false,
    "shorten_font": false,
    "shorten_background": true,
    "shorten_background_min": 2,
    "shorten_margin": false,
    "shorten_padding": false,
    "shorten_list_style": false,
    "shorten_outline": false,
    "shorten_border": false,
    "shorten_border_top": false,
    "shorten_border_right": false,
    "shorten_border_bottom": false,
    "shorten_border_left": false,
    "shorten_border_radius": false,
    
    "format": true,
    "format_4095_rules_legacy_limit": false,
    "format_font_family": true,
    
    "special_convert_rem": false,
    "special_convert_rem_browser_default_px": "16",
    "special_convert_rem_desired_html_px": "10",
    "special_convert_rem_font_size": true,
    
    "special_reduce_with_html" : false,
    "special_reduce_with_html_ignore_selectors" : [
      "@-ms-",
      ":-ms-",
      "::",
      ":valid",
      ":invalid",
      "+.",
      ":-"
    ],
    
    "generate_report": false,
    "verbose": true,
    
    "bypass_media_rules": true,
    "bypass_document_rules": false,
    "bypass_supports_rules": true,
    "bypass_page_rules": false,
    "bypass_charset": false,
    
    "zero_units": "em, ex, %, px, cm, mm, in, pt, pc, ch, rem, vh, vw, vmin, vmax",
    "zero_ignore_declaration": []
    
  }
}

yarn install fails on resolving dependencies

Hi,

I'm working on a project that has a dependency to grunt-css-purge (^1.0.2). When I do yarn install, I receive following error:

error An unexpected error occurred: "Path must be a string. Received { integrity: 'sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=',
  resolved: 'https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz',
  version: '1.0.1' }".

According to the verbose run it comes from css-purge, i.e.:

verbose 19.933 Performing "GET" request to "https://registry.yarnpkg.com/css-purge/-/css-purge-3.0.9.tgz".
verbose 20.213 TypeError: Path must be a string. Received { integrity: 'sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=',
  resolved: 'https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz',
  version: '1.0.1' }
    at assertPath (path.js:28:11)
    at Object.isAbsolute (path.js:460:5)
    at module.exports.exports.default (C:\Program Files (x86)\Yarn\lib\cli.js:97479:16)
    at C:\Program Files (x86)\Yarn\lib\cli.js:53215:63
    at Generator.next (<anonymous>)
    at step (C:\Program Files (x86)\Yarn\lib\cli.js:98:30)
    at C:\Program Files (x86)\Yarn\lib\cli.js:109:13
    at <anonymous>
error An unexpected error occurred: "Path must be a string. Received { integrity: 'sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=',
  resolved: 'https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz',
  version: '1.0.1' }".

I've found that package.json in css-purge repo, there are objects like this:

"dependencies": {
    "amdefine": {
      "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
      "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
      "version": "1.0.1"
    },
    "ansi-regex": {
      "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
      "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
      "version": "2.1.1"
    },
... // omitted

instead of string with package version. Is it valid package.json structure? It looks like entries from package-lock.json, since there is nothing about such an entries in Npm package.json docs (https://docs.npmjs.com/files/package.json).

P.S. I'm using:

node --version
v8.11.2

npm -v
6.1.0 

yarn --version
1.7.0

OS: Windows 10

New "Group Common Decliration Feature" going out live, breaking compilation

Hello, The "new feature" released in version 3.1.0 went out live instead of dark (for some reason) and is generated erroneously unnested selectors.

Here's a gist for comparison:
https://gist.github.com/brookscom4580/916e012af880e06745b1aaaf234d4fa9

In this gist I've added 4 "files":

  • prepurge.css is what we're sending into css-purge
  • 3.0.14_post.css is what has been being compiled before version 3.1.0
  • 3.1.0_post.css is what we're seeing get compiled with version 3.1.0
  • oddity.css calls out the compile issue

I'm sure there is a way to turn off this new feature but given that it went out live it created a quick path to a production issue for us. I expect other people might see the same types of issue as well. Maybe the feature should be set to dark / false by default?

Proposal: remove default browser properties

First of all, thanks for this amazing package :)
Css-purge check for unused properties, what if it also check for useless default properties:

e.g.

.example1 {
  text-align: left; // default in all browser --> remove
}
.example2 {
  color: #000000; // default in all browser --> remove
}

and so on..

Parsing background: url with protocol agnostic url is broken

$ css-purge -c ".foo { background: url("//example.com/test.png") ;}"
CSS Parser Error: probably have something funny in your CSS, change it then please try again.
Reason: missing '}'
Line: 1
Column: 23
$ css-purge -c ".foo { background: url("http://example.com/test.png") ;}"
.foo{background:url(http://example.com/test.png)}

Is there a way to purge media queries of duplicated rules?

Hi, I'd like to purge duplicated rules from inside media queries, but based on #14 this does not seem possible.

Here is what I want to do:

Input:

.panel {
    padding: 10px;
    background-color: blue;
}

@media (prefers-color-scheme: dark) {
    .panel {
        padding: 10px;
        background-color: red;
    }
}

Expected output:

.panel {
    padding: 10px;
    background-color: blue;
}
@media (prefers-color-scheme: dark) {
    .panel {
        background-color: red;
    }
}

Is this possible using css-purge or do you know of a way I could achieve that result?
Thanks

Remove duplicates cross files.

Hi,

I'm trying to modify this to be able to remove the rules form one file that are situated in another file.
I got the basics things, but it seem to be that to be sure, I would need to change the for (i = 0; i < parsedRulesLen; i++) to a double for loop, which annoys me a bit. (I'm not super familiar with css-purge and css-parse)

Do you see any better/smart way to do this ?
Would you be open to a PR that adds the functionality ?

Thanks.

css-purge not removing duplicated css styles

I tried with css-purge cli

Input:

.header__logo {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    margin: 15px 0
}

.header__logo__svg {
    padding-right: 15px;
    margin-right: 15px;
    border-right: 1px solid #000;
    padding-right: 15px;
    margin-right: 15px
}

.header__logo__title {
    text-transform: uppercase;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    text-transform: uppercase;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end
}

Output:

.header__logo {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    margin: 15px 0
}

.header__logo__svg {
    padding-right: 15px;
    margin-right: 15px;
    border-right: 1px solid #000;
    padding-right: 15px;
    margin-right: 15px
}

.header__logo__title {
    text-transform: uppercase;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    text-transform: uppercase;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end
}

Ordering is not preserved on selectors

Hi, I'm really impressed with css-purge so far. Curious to know if there's an option to preserve the ordering of selectors to match the order they were written initially. Take the code below for example:

h1 {
  color: red;
}

h1, h2 {
  color: purple;
}

h1 {
  color: black;
}

I would expect it to output the following

h1, h2 {
  color: purple;
}

h1 {
  color: black;
}

but it actually output this:

$ css-purge -c "h1 { color: red; } h1, h2 { color: purple; } h1 { color: black; }"
h1{color:#000}h1,h2{color:purple}

As you can tell this will not result in the correct thing showing up, the h1 will be color: purple instead of the intended color: black.

(note: this example is incredibly scaled down from the actual problem existing in my codebase where we have +300kb of duplicated styles that we're trying to auto-deduplicate until we can solve the actual problem)

purging large files

Hey there,

I am working with purge now on big files (2215 selectors) and see that it seems to cut off after 1100 selectors. Might there be a limit we are running into here?
I am still investigating and will let you know when I have more infos.

It also seems to have scramble some selectors:

.table-bordered t>thead>tr>th,.table-bordered t>thead>tr>td
                ^------ this is not in the source anywhere

I would gladly provide you with the CSS file I am using and it's result plus verbose log. Just send me a mail(my email is in my npm profile or the package.json in my repo) and I'll send you all infos.

Thanks

css-purge doesn't terminate

I'm on a PC running Windows 7. After running css-purge on a css file, the purged file is created, but css-purge doesn't terminate. I have to ctrl-c to terminate the app.

Grunt plugin

Hey there,

Love this package so I created a grunt plugin for it here.
I know this is not an issue as such but might help people when they see this.

Cheers

Feature Request: support stdin / stdout

For script integration and general utility, it would be nice to have the ability to

  1. cosume stdin as css input
  2. emit processed result on stdout

Current workflow for input seems to assume a signle local file exists with all input. This may not be the case. Direct input building via e.g. *nix cat or input fetching with wget or curl is not possible because of this assumption. A separate file building step is required in these cases.

Current workflow for output always produces a new file decorated with .min intermediate extension if the --output option is omitted. This prevents e.g. quick change detection by piping into md5sum, wc -c and so forth, or further processing by other tools. It also prevents shell-based file redirection.

The usual convention for stdin / stdout processing in command line tools is to either do it by default, in absence of file-specific options, or to recognize - as a ~magic file name referring to either stdin or stdout.

Input could potentially default to stdin. Defaulting output to stdout OTOH would break compatibility with all existing scripts using css-purge.

background image url base64 CSS Parser Error

CSS Parser Error: probably have something funny in your CSS, change it then please try again.
Reason: property missing ':'
Line: 1
Column: 14490
Filename: demo/test1.css

Not all of them, this one can be parsed

background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA2CAMAAAC/bkrSAAAAV1BMVEVHcEy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLRI2JfcAAAAHHRSTlMAZTRs/gNpEOmq9i1AEsp5jUjfVAgml+4qHtKcDjTlBwAAAR1JREFUSMfl1tuOgjAUheGFMm1FAFXAOfzv/5xzoUABQsvEi4muKxPzAaE7myVJtiozopKVlZUk6ezYEHeWpDxlU9Jcsg6cKRSVwjhwVhW4RtFpHFQqIdGGJFAqg2ILsnAToE0BXhytj9N9fGYoMILueei6/njXtzmn/45qu5J6GbWrayltl9AutLt2z0I6re7m7PT+E/E3VOfXpE8cKmZnEUafl9mZ+YvF+/eS9/eZGw81o3n97tAJcPvdIz8AhwHli1uuzsB9dVcwKXD48Gfv5pnu65gD+6kJvYhkGO/BhJABjvef+97EI89EI9/EopGJRGMThyYmVD4McJyaUM0xQDs1oUJlAICReVQ3G0BjE1cSpyamjs5NuPjOzC/J/mac5mZAkwAAAABJRU5ErkJggg==");

This one throws an error:

background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAACuUExURUdwTP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7B471YAAAA5dFJOUwDwl07+9voB/Qa9quveduKFn0INwvsUowlbjtFuAikbL81lfpOcH3tJN9muYFNpWDyL5xC3ybDVIhk4hiwAAAFsSURBVBgZtcDpcppQAIbhDxE4oCiuuOGuUc2qSdv3/m+sM+k0CB7H/MmjH9UZtsZ14526yWug27YVjy/xJJRd9uAB/kdaqRxjgMOrbM4R0H0Z6NN2dYLeRNfOY2julBskBhKVhV2I+ipoO7BUSQJRqJK5gz9XwbRHfNYVt0pXBSm0ZZFCWxf6Pu+ymfm868IzuLKq4XeUq+GFshrCTrnfdGX3BxrKObRklxnWykFFNzhslHPY6AbDWrkDkexm8KDcESeT1RO4yk2gLasW5qzczFCTTd8j0qUjZi6LEbi6NDcsQl3Z91gEKhhBGqhk28TfqyhcQBqqYBpDQ2X9AyzmymVLD6jvVBL0P6CX7vXPYDjmk++qJAjfesCpljQao8gDmisA/0lXpjXDl/qqoxaAedG12eRX04A3rrihpKwFYIay6wz0X7YBMI+6K6gAmKXuCtYA1WfdFYwAqo+67w2grm9IgFjf0XDitn7AX5YQNKt9rKhYAAAAAElFTkSuQmCC"); }

And looks like anything with "/////////////////////////////////////..." in it will cause the error.

Wrong css generated!

Input
div:before { content: " "; width: 0; height: 0; position: absolute; border-style: solid; border-width: 0 10px 10px 0; border-color: transparent #494949 transparent transparent; left: 0px; bottom: -10px; }
Output:

div:before { content: " "; width: 0; height: 0; position: absolute; border: 0 10px 10px 0 solid transparent #494949 transparent transparent; left: 0; bottom: -10px; }

Border is a invalid property value.

I also have set this options:

{ trim : false, shorten : false, verbose : true }

Error scanning directory with node 6 on nvm

Using node 6.6 on nvm, there seems to be an issue with scandir, it seems to be scanning relative to the path of the css-purge module rather then the absolute path of the dir

Running this command:
css-purge -i /absolute-path/to/css -o static/all.css

Directory read error: Something went wrong while reading the directory, check your [html] in config_css.json and please try again.
{ Error: ENOENT: no such file or directory, scandir '/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/absolute-path/to/css'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)
    at getFilePaths (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1999:10)
    at CSSPurgeEmitter.continueCSSFilesProcessAfterConfig (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1861:9)
    at emitOne (events.js:96:13)
    at CSSPurgeEmitter.emit (events.js:188:7)
    at readConfig (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1714:14)
    at CSSPurgeEmitter.continueCSSFilesProcess (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1908:5)
    at emitOne (events.js:96:13)
    at CSSPurgeEmitter.emit (events.js:188:7)
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: '/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/absolute-path/to/css' }

BTW, this works, providing the specific file

css-purge -i /absolute-path/to/css/one.css -o static/all.css

Wrong file size after and saved

I'm using gulp-css-purge v3.0.9. In package-lock.json css-purge installed is v3.1.8.
When I use the verbose options, it gives me:

Before: 382.765KB
After: 0.33931KB
Saved: 382.4257KB (99.91%)

But the file after purged is 339KB, not 0.339KB

Handle/output CSS files with CRLF eol

Does not handle blank lines and comments in CSS files with CRLF eol
Input file...
/* Comment 1 /CRLF
/
Comment 2 /CFLF
/
Comment 3 /CRLF
Outputs...
/
Comment 1 /LF
LF
/
Comment 2 /LF
LF
/
Comment 3 */LF

Unsafe transforms

I have noticed this tool makes some unsafe transforms:
Input CSS:

.entry-title {
  line-height: 1.3;
  color: #222;
}

.entry-title a {
  color: #222;
}

.entry-title a:hover {
  color: #666;
}

Output CSS:

.entry-title {
  line-height: 1.3;
  color: #666;
}

.entry-title a {
  color: #222;
}

Here is another simple example:
Input:

small {
  font-size: 80%
}
small {
  font-size: 85%
}

Output:

small {
  font-size: 80%
}

CSS-Purge didn't do anything to my test file

I couldn't find any examples of what CSS-Purge does, so I don't know what to expect from it. I tried it out with this input file:

.test {
    color: red;
    color: blue;
    font-weight: bold;
}
.test2 {
    color: green;
}
.test2 {
    color: green;
    color: green;
}
.test {
    color: purple;
}
.invalidProperties {
    invalid:property;
}

I expected the output to be:

.test {
    font-weight: bold;
}
.test2 {
    color: green;
}
.test {
    color: purple;
}
.invalidProperties {
    invalid:property;
}

Instead, this is what CSS-Purge actually output:

.test {
    color: red;
    color: blue;
    font-weight: bold;
}
.test2 {
    color: green;
}
.test2 {
    color: green;
    color: green;
}
.test {
    color: purple;
}
.invalidProperties {
    invalid: property;
}

What should I have expected? What kinds of redundancies and duplicates is CSS-Purge supposed to find?

I analize all files in folder and minimize all to same folder

Hello, first of all I'm sorry for my English, I'm getting help from Google Translate.

I'm using your library to clean up my CSS and reduce the files and would like to know if there's any way I can get all the files in a directory and minimize them to the same directory but with the postfix '.min.css'.

Today I have the script in my package.json file so:

{
    ...
    "scripts": {
        "build:css:prod":"css-purge -i css/index.js -o css/index.min.js"
    ...
    }
}

But I have other files in the directory ... I even tried to use regular expressions, or setting the directory to the input and also to the output but the library does not work.

Is there any way (using your library) to compile all the files in the directory to the same name? (as in the example below):

before:

css/
 |- App.css
 |- Foo.css
 |- Bar.css

after:

css/
 |- App.css
 |- App.min.css // minified
 |- Foo.css
 |- Foo.min.css // minified
 |- Bar.css
 |- Bar.min.css // minified

Purge removes browser prefixed @keyframe rules

When I run
css-purge -i styles.css -o styles.css -w

My output for some @Keyframe rules goes from:

@-webkit-keyframes tooltip-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@-moz-keyframes tooltip-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@-ms-keyframes tooltip-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes tooltip-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

to

@keyframes tooltip-fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}


@keyframes tooltip-fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}


@keyframes tooltip-fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}


@keyframes tooltip-fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

Is this a setting I have incorrect in my parameters?

Is there a way to get css-purge to ignore keyframe rules?

Can we stop using proccess.exit(1)?

This way to exit code causes a lot of trouble when you just want to try/catch the exception. It caused the whole program to just stop when running on nodejs app.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.