Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
gulp-clean-css
Advanced tools
gulp-clean-css is a Gulp plugin for minifying CSS files using the clean-css library. It helps in reducing the size of CSS files by removing unnecessary whitespace, comments, and other redundant elements, which can improve the performance of web applications.
Basic Minification
This feature allows you to perform basic minification of CSS files. The code sample demonstrates how to set up a Gulp task to minify CSS files from the 'src' directory and output the minified files to the 'dist' directory.
const gulp = require('gulp');
const cleanCSS = require('gulp-clean-css');
gulp.task('minify-css', () => {
return gulp.src('src/*.css')
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(gulp.dest('dist'));
});
Advanced Minification Options
This feature allows you to use advanced minification options provided by clean-css. The code sample shows how to set the 'level' option to 2 for more aggressive optimizations.
const gulp = require('gulp');
const cleanCSS = require('gulp-clean-css');
gulp.task('minify-css-advanced', () => {
return gulp.src('src/*.css')
.pipe(cleanCSS({ level: 2 }))
.pipe(gulp.dest('dist'));
});
Source Maps
This feature allows you to generate source maps for the minified CSS files. The code sample demonstrates how to initialize and write source maps using the 'gulp-sourcemaps' plugin in conjunction with 'gulp-clean-css'.
const gulp = require('gulp');
const cleanCSS = require('gulp-clean-css');
const sourcemaps = require('gulp-sourcemaps');
gulp.task('minify-css-sourcemaps', () => {
return gulp.src('src/*.css')
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
gulp-csso is another Gulp plugin for minifying CSS files, using the CSSO library. It offers similar functionality to gulp-clean-css but uses a different underlying library for minification. CSSO is known for its aggressive optimizations and may produce smaller file sizes in some cases.
gulp-uglifycss is a Gulp plugin for minifying CSS files using the UglifyCSS library. It provides basic minification capabilities similar to gulp-clean-css but may not offer as many advanced options or optimizations.
gulp-postcss is a Gulp plugin that allows you to use PostCSS plugins to process CSS files. While not a minifier itself, it can be used with plugins like cssnano to achieve minification. This makes it a more flexible but potentially more complex solution compared to gulp-clean-css.
Minify files with CleanCSS
This package is marked as deprecated. Please use jonathanepollack/gulp-minify-css instead.
npm install --save-dev gulp-clean-css
var minify = require('gulp-clean-css');
gulp.task('compress', function() {
return gulp.src('assets/stylesheets/*.css')
.pipe(minify())
.pipe(gulp.dest('dist'))
});
This package is heavily inspired (actually it's a clone..) by terinjokes/gulp-uglify.
Also take a look at jonathanepollack/gulp-minify-css. The only reason I made this clone is the fact that Node was throwing some low-level errors..
FAQs
Minify css with clean-css.
The npm package gulp-clean-css receives a total of 36,372 weekly downloads. As such, gulp-clean-css popularity was classified as popular.
We found that gulp-clean-css demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.