postcss-slash-css

1.1.0 • Public • Published

postcss-slash-css

Build Status

A PostCSS plugin that removes duplicates css properties and selector accross multiples css files.

Installation

npm install postcss-slash-css

This plugin only supports node v8.0.0 and over.

Usage

const postcss = require("postcss");
const slashCSS = require("");
 
postcss([slashCSS({ targets: "**/*.css" })]);

See PostCSS docs for examples for your environment.

Example with gulp :

const postcss = require('gulp-postcss');
const gulp = require('gulp');
const slashCSS = require("../../index");
 
const inputFilePath = "../assets/normal.css";
const targetFilePath = "../assets/*.critical.css";
const outputFilePath = "./result.css";
 
// plugin we will use in postcss
const pluginsUsed = [
  slashCSS({ targets: targetFilePath })
];
 
gulp.task('css', function () {
  return gulp.src(inputFilePath)
    .pipe(postcss(pluginsUsed))
    .pipe(gulp.dest(outputFilePath));
});

Options

targets

  • Type: string (glob using fast-glob)
  • Required

CSS files to search duplicates within source file.

mode

  • Type: string (not case sensitive)
  • Optional
  • Default: MatchAtleastOne

Can be MatchAtleastOne or MatchAll.

If MatchAll is used, css will be removed only if it is present in ALL targets files. If MatchAtleastOne is used, css will be removed when it is present ATLEAST in one of targets css files.

checkImportant

  • Type: boolean
  • Optional
  • Default: true

if false two properties are equals even if one has important and the other does not have it.

Testing

To test this plugin, just run :

npm test

Example

You can see multiples exemples in the example folder.

License

This software is released under the terms of the MIT license.

Package Sidebar

Install

npm i postcss-slash-css

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

15.8 kB

Total Files

23

Last publish

Collaborators

  • gatsbill