Despre metoda watch

postat acum 2 ani de Stefanescu Mihai in categorie Gulp

Metoda Watch este folosita pentru a-ti monitoriza fisierele sursa. Cand apare o schimbare in fisier, task-ul necesar va fi rulat automat. Putem folosi task-ul default scris mai devreme pentru a monityoriza schimbarile din HTML, CSS si JavaScript.

Cum facem watch petaskul Default

In articolul trecut am discutat despre cum putem combina task-urile folosindu-ne de un 'task' default. Am folosit gulp-minify-css, gulp-autoprefixer si gulp-concat pentru a face un task numit 'styles' ce va face minify pe fisierele CSS.

Pentru a urmari modificarile din CSS trebuie sa modificam putin codul din task-ul default:

gulp.task('default', ['styles'], function() {
   // urmarim modificarile din CSS
   gulp.watch('src/styles/*.css', function() {
      // rulam styles cand se modifica ceva
      gulp.run('styles');
   });});

Acum toate fisierele din  invata-programare/src/styles sunt urmarite pentru orice schimbare si comanda styles va fi executata.

Rularea taskului Default

Pentru a rula acest task default folosim comanda aceasta:

gulp

Dupa ce am executat comanda ne va fi afisat mesajul acetsa

C:\invata-programare>gulp
[17:11:28] Using gulpfile C:\invata-programare\gulpfile.js
[17:11:28] Starting 'styles'...[17:11:28] Finished 'styles' after 22 ms
[17:11:28] Starting 'default'...[17:11:28] Finished 'default' after 21 ms

Cand apare o schimbare o sa vedem acest mesaj:

C:\invata-programare>gulp
[17:11:28] Using gulpfile C:\invata-programare\gulpfile.js
[17:11:28] Starting 'styles'...[17:11:28] Finished 'styles' after 22 ms
[17:11:28] Starting 'default'...[17:11:28] Finished 'default' after 21 ms
gulp.run() has been deprecated. Use task dependencies or gulp.watch task 
   triggering instead.[17:18:46] Starting 'styles'...[17:18:46] Finished 'styles' after 5.1 ms

Acest proces va ramane activ si va raspunde la orice schimbare a fisierelor din folder. Pentru a opri acest proces apasam Ctrl+C

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 yeezy boost 350 v2 la data de 14.05.2019
I together with my friends came studying the excellent suggestions from the blog then quickly I got an awful suspicion I never thanked the web site owner for those techniques. All the young men are already as a result passionate to see them and have in effect absolutely been taking pleasure in those things. Appreciation for truly being simply considerate and for picking out certain wonderful guides millions of individuals are really desirous to understand about. My personal sincere apologies for not expressing appreciation to you earlier.
Comentariu postate de how to download minecraft la data de 15.05.2019
Wow, fantastic blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is magnificent, as well as the content!
Comentariu postate de minecraft for free la data de 15.05.2019
First off I want to say superb blog! I had a quick question in which I'd like to ask if you do not mind. I was curious to find out how you center yourself and clear your mind prior to writing. I have had a hard time clearing my mind in getting my thoughts out there. I truly do enjoy writing however it just seems like the first 10 to 15 minutes are generally lost simply just trying to figure out how to begin. Any recommendations or tips? Many thanks!
Comentariu postate de michael kors outlet store la data de 16.05.2019
My husband and i felt quite delighted that Emmanuel could conclude his basic research through your ideas he had when using the web site. It is now and again perplexing just to always be giving for free tips and tricks some people have been making money from. Therefore we remember we have the writer to thank for that. The illustrations you made, the straightforward blog navigation, the relationships you will aid to create - it is most excellent, and it's letting our son and our family recognize that that matter is cool, and that's pretty vital. Many thanks for all!
Comentariu postate de minecraft download mojang la data de 16.05.2019
Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! By the way, how could we communicate?
Comentariu postate de minecraft download mojang la data de 17.05.2019
I have read so many posts concerning the blogger lovers however this article is in fact a fastidious piece of writing, keep it up.
Comentariu postate de how to download minecraft free la data de 17.05.2019
Ahaa, its pleasant dialogue on the topic of this paragraph at this place at this website, I have read all that, so now me also commenting here.