Today continue to talk about Gulp watch, can take the initiative to take care of a lot of things. You don't have to knock on orders every time!
The last time I talked about using Gulp can be very convenient for css,js,html compression. and the ability to compile coffee and scss.
Css,js. HTML is generally published production time compression can be, that is, the Gulp command to knock once. However, coffee and scss these two dev time will be modified from time-to-time files, assuming each modification, it is necessary to manually knock gulp to compile the problem.
So here's the problem.
Assuming that you can change the coffee and scss each time you can actively compile into JS and CSS will be a very happy thing!
Gulp won't disappoint you, of course, it provides a solution. That's watch.
Watch is actually simpler than that. is to keep an eye on whether certain files have changed. If the assumptions change, then some operations are performed.
Eat a chestnut.
Gulp.task (' Watch ', [' coffee '], function () {
Gulp.watch (' App/assets/coffee/*.coffee ', function (event) {
GULP.SRC (Event.path)
. Pipe (Coffee ({bare:true}). On (' Error ', Gutil.log))
. Pipe (Gulp.dest (' app/assets/javascripts '));
});
});
Already on the code is to take the initiative to turn coffee JS role.
It means. Create a task whose name is watch (of course, you pick up the name). The content is to run the task called coffee, which I created earlier.
Then take watch all the coffee files.
Assuming the coffee file changes, the file is targeted for changes. Make a compile once. Generate a new JS to JavaScripts folder.
It's that simple. is so capricious, is so powerful!
Thank you for reading this article, like, please share this article to the friend Circle, orrecommend to your friends,is the greatest support and encouragement to me. Another QQ group: 107584987.
All technical articles can be found in my csdn Blog http://blog.csdn.net/tommychen1228
Gulp Help yourself to take care of coffee and Scss's compile.