All Projects → Rammfall → postcss-trash-killer

Rammfall / postcss-trash-killer

Licence: MIT license
It is a postcss plugin which wil be remove all unused css

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to postcss-trash-killer

Postcss Import
PostCSS plugin to inline @import rules content
Stars: ✭ 1,048 (+5140%)
Mutual labels:  postcss, postcss-plugin
Postcss Less
PostCSS Syntax for parsing LESS
Stars: ✭ 93 (+365%)
Mutual labels:  postcss, postcss-plugin
Postcss Triangle
PostCSS plugin to create a triangle.
Stars: ✭ 57 (+185%)
Mutual labels:  postcss, postcss-plugin
Postcss Register Custom Props
PostCSS plugin that transforms custom property registration in CSS to JS
Stars: ✭ 20 (+0%)
Mutual labels:  postcss, postcss-plugin
Postcss Aspect Ratio Mini
A PostCSS plugin to fix an element's dimensions to an aspect ratio
Stars: ✭ 123 (+515%)
Mutual labels:  postcss, postcss-plugin
Postcss Icon
PostCSS plugin that adds `css icons` from icon sets
Stars: ✭ 20 (+0%)
Mutual labels:  postcss, postcss-plugin
Postcss Prefix Selector
Prefix all CSS rules with a selector
Stars: ✭ 75 (+275%)
Mutual labels:  postcss, postcss-plugin
Postcss Easing Gradients
PostCSS plugin to create smooth linear-gradients that approximate easing functions.
Stars: ✭ 689 (+3345%)
Mutual labels:  postcss, postcss-plugin
Container Query
A PostCSS plugin and Javascript runtime combination, which allows you to write container queries in your CSS the same way you would write media queries.
Stars: ✭ 119 (+495%)
Mutual labels:  postcss, postcss-plugin
Postcss Plugins
The "officially unofficial" consolidated list of PostCSS plugins in a ready-to-use package
Stars: ✭ 107 (+435%)
Mutual labels:  postcss, postcss-plugin
Postcss Banner
PostCSS plugin to add text banner and footer to resulting file
Stars: ✭ 13 (-35%)
Mutual labels:  postcss, postcss-plugin
Postcss Rtl
PostCSS plugin for RTL-adaptivity
Stars: ✭ 143 (+615%)
Mutual labels:  postcss, postcss-plugin
Postcss Interpolate
PostCSS plugin for values interpolation between breakpoints.
Stars: ✭ 9 (-55%)
Mutual labels:  postcss, postcss-plugin
Postcss Alias
PostCSS plugin that allows you to create aliases for CSS properties
Stars: ✭ 47 (+135%)
Mutual labels:  postcss, postcss-plugin
Postcss Position
PostCSS plugin that adds shorthand declarations for position attributes
Stars: ✭ 26 (+30%)
Mutual labels:  postcss, postcss-plugin
Postcss Nested Props
PostCSS plugin to unwrap nested properties.
Stars: ✭ 58 (+190%)
Mutual labels:  postcss, postcss-plugin
Postcss Responsive Type
Automagical responsive typography, built on PostCSS
Stars: ✭ 363 (+1715%)
Mutual labels:  postcss, postcss-plugin
Postcss Sprites
Generate sprites from stylesheets.
Stars: ✭ 402 (+1910%)
Mutual labels:  postcss, postcss-plugin
Rtlcss
Framework for transforming Cascading Style Sheets (CSS) from Left-To-Right (LTR) to Right-To-Left (RTL)
Stars: ✭ 1,363 (+6715%)
Mutual labels:  postcss, postcss-plugin
Postcss Viewport Height Correction
PostCSS plugin to solve the popular problem when 100vh doesn’t fit the mobile browser screen.
Stars: ✭ 137 (+585%)
Mutual labels:  postcss, postcss-plugin

Travis CI on linux

This plugin will be kill your unused css

Why do you need this?

Your css is increasing after each iteration? Coverage of pages smaller 5%? This plugin try to clear all trash in your styles.

Example

Your html(haml, jsx, js, etc) have only classes .container, .row, col-12:

<div class="container">
  <div class="row">
    <div class="col-12">
      <h1>Hello!</h1>
    </div>
  </div>
</div>

But in styles you import all bootstrap grid

@import '~bootstrap/scss/grid';

In result you have 99% useless css code. If you add this plugin to your postcss config in result you have only styles, that you use:

.container {
  /* ...code... */
}
.row {
  /* ...code... */
}
.col-12 {
  /* ...code... */
}
@media screen and (max-width: 300px) {
    .container {
      /* ...code... */
    }
    .row {
      /* ...code... */
    }
    .col-12 {
      /* ...code... */
    }
}
/* etc */

1. Installation

npm i -D postcss-trash-killer
yarn add --save postcss-trash-killer

2. Configuration

After install add this plugin to your plugin 'pipeline'

// postcss.config.js
const autoprefixer = require('autoprefixer');
const cssTrashKiller = require('postcss-trash-killer');

const configForCleaner = {
  tagSelectors: false, // default true, include all simple tag selectors(html, body, *, h1, but not `.className h1`
  fileExtensions: ['.haml', '.js'], // File types for scanning selectors
  paths: ['app/view/', 'some/second/path'], // Paths with your view files
  libs: ['slick-carousel'], // Include lib, who work with view and installed via npm(yarn) and located in node_modules in root dir
  libsExtension: ['.js'], // File types for libraries
  whitelist: ['dontTouchSelector'], // not removable selectors
  dynamicSelectors: ['theme-color'] // If you use dynamic selectors, insert here part of selector. Not removed all selectors if contains 'theme-color' part
};

module.exports = {
  plugins: [
    cssTrashKiller(configForCleaner),
    autoprefixer
  ]
}

Note!

This plugin in addition remove empty media queries!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].