I want to minify any css in my folder, where i use gulp-clean-css plugin for gulp.
My code is:
gulp.task('CSS-Pack', function () {
return gulp.src(['Content/App.css', './Content/ApprovalForm.css'])
.pipe(concat('stylesheets.css'))
.pipe(cleanCSS({ debug: true }, function (details) {
console.log(details.name + ': ' + details.stats.originalSize);
console.log(details.name + ': ' + details.stats.minifiedSize);
}))
.pipe(gulp.dest('build/'));
});
gulp.task('CSS-PackAll', function () {
return gulp.src('Content/*.css')
.pipe(concat('stylesheets.css'))
.pipe(cleanCSS({ debug: true, specialComments: false }, function (details) {
console.log(details.name + ': ' + details.stats.originalSize);
console.log(details.name + ': ' + details.stats.minifiedSize);
}))
.pipe(gulp.dest('build/'));
});
My task CSS-Pack works, but where i start task CSS-PackAll i have following error:
Where i use minify-css(i want to use gulp-clean-css, because minify-css is depricated) plugin CSS-PackAll working..
:\Users\gkv\TFS\SharePoint Online\LirexAddHolidayRequest\node_modules\gulp-clean-css\node_modules\clean-css\lib\reader\rewrite-url.js:45 return path.isAbsolute(uri); ^ TypeError: Object # has no method 'isAbsolute' at isAbsolute (C:\Users\gstev\TFS\SharePoint Online\LirexAddHolidayRequest\node_modules\gulp-clean-css\node_modules\clean-css\lib\reader\rewrite-url.js:45:15) at rebase (C:\Users\gkrystev\TFS\SharePoint Online\LirexAddHolidayRequest\node_modules\gulp-clean-css\node_modules\clean-css\lib\reader\rewrite-url.js:23:7) at rewriteUrl (C:\Users\gkrystev\TFS\SharePoint Online\LirexAddHolidayRequest\node_modules\gulp-clean-css\node_modules\clean-css\lib\reader\rewrite-url.js:114:5) at rebaseSourceMapComment (C:\Users\gkrystev\TFS\SharePoint Online\LirexAddHolidayRequest\node_modules\gulp-clean-css\node_modules\clean-css\lib\reader\rebase.js:78:45) Process terminated with code 8.
I realise that strictly speaking this isn't an answer to your problem, but I hit this exact error when using gulp-clean-css to minify our CSS and tracked the problem to a single line in our source:
background-image: url('/img/cloader.gif') no-repeat center top;
It appears to be a problem processing a relative URL; in our case, we no longer needed this style and removing it resolved the problem. Hope this helps.