javascriptgulpgulp-clean-css

Gulp is creating a directory instead of a file


I want gulp to spit out a style.min.css:

// Minify
gulp.task('minify-css', function () {
    gulp.src('css/style.css')
        .pipe(cleanCSS())
        .pipe(gulp.dest('css/style.min.css'))
});

it is minifying the .css but instead is creating a directory with a style.css in it:

css/style.min.css/style.css

Any help? Thanks.


Solution

  • gulp.dest writes to directories. You should add a rename step before piping to gulp.dest.

    .pipe(rename('style.min.css'))
    .pipe(gulp.dest('css/'))
    

    You should be able to use the gulp-rename module for this.