The watch task
So far, all of the tasks that we have written are actually only capable of running once. Once they complete, their job is considered done. However, this isn't very helpful as we would end up having to go back to our command line to run them again every time we make a change to our files. This is where Gulp's .watch
method comes into play. The watch method's job is to specifically look for changes to files and then respond by running tasks in relation to those changes. Since we will be focusing on CSS, JavaScript, and images independently, we will need to specify three separate watch methods as well. To better organize these watch methods, we will create an additional watch task that will serve as a container and an easy way to reference all of the watch method calls inside of our gulpfile
.
Writing the watch task
Since the watch method is built into Gulp as a core feature, no new plugins are needed. So, we can move straight to actually writing the task itself. Additionally, it...