Combinarea de taskuri

postat acum 2 ani de Stefanescu Mihai in categorie Gulp

Taskurile ne permit sa configuram Gulp intr-un mod modular.Trebuie sa facem cate un task pentru fiecare dependenta, ceea ce inseamna ca trebuie sa gasim si sa instalam plugin-uri ce ne sunt necesare.

Instalarea de plugin-uri

Hai sa ne uitam la acest plugin numit minify-css care uneste fisierele css si le face minify. Poate fi instalat folosind urmatoarea comanda:

npm install gulp-minify-css --save-dev

Pentru a folosi acest plugin trebuie sa instalam inca un plugin numit "gulp-autoprefixer"

npm install gulp-autoprefixer --save-dev

Pentru a concatena fisierele CSS trebuie sa instalam si plugin-ul "gulp-concat"

npm install gulp-concat --save-dev

Dupa ce am instalat aceste plugin-uri trebuie sa scriem dependintele in fisierul de configurare:

var autoprefix = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var concat = require('gulp-concat');

Adaugarea unui task in Gulp

Acum trebuie sa facem cate un task pentru fiecare dependinta.

gulp.task('styles', function() {
   gulp.src(['src/styles/*.css'])
   .pipe(concat('styles.css'))
   .pipe(autoprefix('last 2 versions'))
   .pipe(minifyCSS())
   .pipe(gulp.dest('build/styles/'));});

Plugin-ul 'concat' va concatena toate fisierele intr-un singur fisier, plugin-ul 'autoprefix' adauga prefixele necesare in functie de browsere, iar minifyCSS cred ca este destul de usor de inteles ce face.

Pentru a rula acest task rulam urmatoarea comanda in folderul proiectului

gulp styles

Combinarea mai multor task-uri

Putem rula mai multe task-uri facand un task default in fisierul de configurare:

gulp.task('default', ['imagemin', 'styles'], function() {

});

Fisierul gulp este gata de executie. Rulam codul de mai jos pentru a rula task-urile combinate:

gulp

 

Sunt un tanar programator din Bucuresti ce lucreaza in PHP/Mysql (MySqli/PDO), Laravel, CodeIgniter, MySQL, PostgreSQL, Wordpress, HTML5/CSS3, Sass, Photoshop si multe altele.
Google+ Community Facebook Group

Comentariu postate de minecraft download free pc la data de 14.05.2019
This is my first time go to see at here and i am in fact happy to read all at one place.
Comentariu postate de lebron james shoes la data de 14.05.2019
I not to mention my guys came looking at the excellent solutions on your site and then before long came up with an awful feeling I had not thanked you for them. My women are actually for this reason thrilled to read through all of them and have now seriously been making the most of those things. Many thanks for genuinely well helpful as well as for getting variety of brilliant things millions of individuals are really wanting to learn about. My sincere regret for not saying thanks to sooner.
Comentariu postate de minecraft download mojang la data de 16.05.2019
When some one searches for his necessary thing, therefore he/she needs to be available that in detail, therefore that thing is maintained over here.
Comentariu postate de download minecraft free la data de 17.05.2019
I am regular visitor, how are you everybody? This piece of writing posted at this website is in fact nice.