File Minification in Gulp
Let's now learn how to apply operations to a set of files. First, we will minimize CSS files. This is done using the gulp-clean-css plugin.
First, this plugin must be installed in our project:
terminalnpm install gulp-clean-css --save-dev
After that, import the installed plugin:
javascriptlet {src, dest} = require('gulp');
let cleanCSS = require('gulp-clean-css');
Use it for some file:
javascriptfunction task(cb) {
return src('src/styles.css')
.pipe(cleanCSS())
.pipe(dest('dist'));
}
Use our plugin for a group of files:
javascriptfunction task(cb) {
return src('src/*.css')
.pipe(cleanCSS())
.pipe(dest('dist'));
}
Задание 1
Using the gulp-uglify plugin, minimize a group of JavaScript files.