GithubHelp home page GithubHelp logo

rbtech / gulp-css-purge Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 206 KB

CSS-PURGE now comes in a flavor thats meant to be Gulped

License: MIT License

JavaScript 100.00%
gulp gulp-plugin css-purge remove-duplicates minify-css clean-css

gulp-css-purge's Introduction

gulp and CSS-PURGE

Gulp CSS-PURGE

Purges duplicate CSS rules and more. Based on css-purge.

You have an issue?

This is a simple gulp plugin, which means it's a thin wrapper around css-purge. If you are having CSS issues, please contact css-purge. Please only create a new issue if it looks like you're having a problem with the gulp plugin.

Install

npm install gulp-css-purge --save-dev

Options

Visit the CSS-PURGE website

Example 1 - Multiple CSS files merged into single CSS file - Full Working Example

var gulp = require('gulp'),
    concat = require('gulp-concat'),
    purge = require('gulp-css-purge');

gulp.task('default', function() {
  return gulp
        .src(['./**/*.css']) //input css
        .pipe(concat('main.css')) //merge into single css file - remove if you want to process output into separate files
        .pipe(purge({
            trim : true,
            shorten : true,
            verbose : true
        }))
        .pipe(gulp.dest('build/css')) //output folder
});

Example 2 - SASS

var gulp = require('gulp'),
    sass = require('gulp-ruby-sass'),
    purge = require('gulp-css-purge'),
    minify = require('gulp-minify-css');

gulp.task('default', function() {
  gulp.src(['./**/*.sass'])
    .pipe(sass())
    .pipe(purge())
    .pipe(gulp.dest('./public'));
})

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.

gulp-css-purge's People

Contributors

andreweq avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sequencemedia

gulp-css-purge's Issues

hsla saturation and lightness

when hsla() or hsl() is used if the saturation and/or lightness has a value of 0% the output css removes value.
hsla(0, 0%, 60%, 0.6) outputs to hsla(0,, 60%, 0.6)
hsl(123, 10%, 0%) outputs to hsl(123,10%,,)

Purge works with CLI but not Gulp

I've encountered an issue wherein I'm trying to purge a (third-party) CSS file and I'm getting the following error:

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

There is no missing } in the line mentioned nor anywhere else in the file as far as I'm aware. The filename is also not demo/test1.css.

Here is my Gulp code:

const gulp = require('gulp');
const concat = require('gulp-concat');
const streamqueue = require('streamqueue');
const cssPurge = require('gulp-css-purge');

// Concatenate and minify stylesheets
gulp.task('styles', function() {
    // inspired by https://stackoverflow.com/a/23507836
    return streamqueue({ objectMode: true },
        gulp.src('./node_modules/purecss/build/pure.css'),
        gulp.src('./static/app.css'),
        gulp.src('./node_modules/codemirror/lib/codemirror.css'),
    )
    .pipe(concat('styles.css'))
    .pipe(cssPurge({
        trim : true,
        shorten : true,
        verbose : false
    }))
    .pipe(gulp.dest('./static'));
});

The problem is with the ./node_modules/codemirror/lib/codemirror.css file because when I comment this line I can purge the other two without issues. The problem is also not with concatenation or the use of streamqueue because even without it I get the same error.

Now, the following run from CLI works without any problem and produces a valid minified CSS file:

./node_modules/.bin/css-purge -i ./node_modules/codemirror/lib/codemirror.css

Therefore I assume there's a problem in this package and not in css-purge itself.

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.