postcss-slash-css
PostCSS plugin to remove duplicate css between multiple files
Last updated 2 years ago by gatsbill .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install postcss-slash-css 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 1.1.0                                ...           latest (2 years ago)

3 Versions

  • 1.1.0                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |