Gulp Help yourself to take care of coffee and Scss's compile.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.