rbtech / gulp-css-purge

CSS-PURGE now comes in a flavor thats meant to be Gulped
MIT License
6 stars 1 forks source link

Purge works with CLI but not Gulp #2

Open LukasRos opened 5 years ago

LukasRos commented 5 years ago

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.

AndrewEQ commented 5 years ago

Hey @LukasRos, can you please share the CSS files for me to have a look at what's happening with that specific combination?

LukasRos commented 5 years ago

This is the file in question: https://raw.githubusercontent.com/codemirror/CodeMirror/7ecf62faa30fb0de99b76609f16c58a7bf032820/lib/codemirror.css

AndrewEQ commented 4 years ago

Sorry its been awhile, been really busy, will take a look at it soon @LukasRos