scniro/gulp-clean-css

clean-css options not working

ecnepsnai opened this issue · 3 comments

I'm having trouble disabling a specific rule for clean-css using gulp-clean-css, when I try my config out using the web interface: https://jakubpawlowicz.github.io/clean-css/ it works as intended but when I try it using gulp it doesn't work.

Here's the relevant gulp code:

gulp.src(['./fonts/*.css'])
    .pipe(concat('fonts.css'))
    .pipe(cleanCSS({
        level: {
            1: {
                normalizeUrls: false
            }
        }
    }))
    .pipe(gulp.dest(BUILD_DIRECTORY_BASE + '/assets/css'));

I also tried:

gulp.src(['./fonts/*.css'])
    .pipe(concat('fonts.css'))
    .pipe(cleanCSS({
        normalizeUrls: false
    }))
    .pipe(gulp.dest(BUILD_DIRECTORY_BASE + '/assets/css'));

As a troubleshooting step I also noticed that setting the level to 0 (which is supposed to disable all optimization) does nothing and still minifies the css

gulp.src(['./fonts/*.css'])
    .pipe(concat('fonts.css'))
    .pipe(cleanCSS({
        level: 0
    }))
    .pipe(gulp.dest(BUILD_DIRECTORY_BASE + '/assets/css'));

I'm using gulp-clean-css 3.9.3 on node.js 9.5.0

@ecnepsnai You appear to be using the clean-css API correctly, I have no idea why it wouldn't work for you as this plugin is just passing the options along. Can you throw together a small reproduction repo that uses the gulp plugin and the clean-css node api that demonstrates the difference in results?

@ecnepsnai closing as I find it unlikely that the options passed are not working - there would be droves of consumers here all reporting similar. Please reopen if you can add additional detail or demonstrate the problem.

I seem to have the same trouble, with gulp-clean-css 3.9.4, gulp 3.9.1 and node 8.11.1.

I noticed the weirdest thing, though. If I set optimisations to level 0, it will still optimise everything EXCEPT comments in the classic /* comment */ syntax. // Comments like this will still be stripped, however.