未加星标

Implementation of Gulp.js from Scratch

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Areyou tired of doing the same things manually i.e., creating the folders, compiling and copying the files deploying them on separate environments (i.e., dev or prod) manually. A lot of mouse clicking, lot of copy-paste, a lot of configuration changes and of course loads of headache.

Then this blog is for you.

I hope after this blog your search ends for implementing gulp in your project and brings you the clarity.

Today we’ll be covering following subjects in this post:

Basics of gulp. Setting the gulp. Running a simple task through gulp.

So, enough of chit-chats, lets jump !!

What exactly is GULP ?

Gulp is a task/build runner for development. It allows you to do a lot of stuff within your development workflow. You can compile SASSfiles, uglify and compress the .js files and much more. The kicker for gulp is that it is a streaming build system which doesn’t write temporary files. It is like Pipes in bash.

In simple terms “ Gulp is a tool by which we can automate repetitive tasks . It won’trevolutionize your automation but simplifies it tremendously.”

Whyuse GULP ?

Lets take a hypothetical scenario, suppose you have an app named as sampleApp, andto seethis application in action you have to perform series of following hypothetical tasks:

Creating and copying the files to development/production environment folder. Creating concatenated, minified and uglified version of application files. Change the configuration file according to the development/production environment. some other extra tasks….

Yes !! you can do these tasks manually but for how long? To save you a lot of time and to save you from boredom,gulp will play like Tony Stark jarvis :p

This is because you will be focusing on your functionality and nothing else.

Installation

Gulp is easy to install and to run. The steps are:

Install Gulp Globally. Initialize your project directory Install Gulp In devDependencies. Create a gulpfile.js Run gulp.

You need to have Node.js (Node) installed onto your computer before you can install Gulp.

If you do not have Node installed already, you can get it by downloading the package installer from Node’s website .

When you’re done with installing Node, you can install Gulp by using the following commands in the command line:

The first step is to get gulp installed globally.

Note: If you have previously installed a version of gulp globally, please run npm rm global gulp to make sure your old version doesn’t collide with gulp-cli.

$ npm install --global gulp-cli

Make sure that you have your package.json created . You can either create it manually or typewrite below command.

$ npm init

After that, you’ll need gulp as a devDependency on any of your project you want to use it in. Once you have your package.json , let’s install gulp into devDependencies with:

$ npm install --save-dev gulp $ npm install --save-dev gutil

Create a gulpfile.js at the root of your project:

var gulp = require('gulp'); var gutil = require('gulp-util'); gulp.task('default', function() { return gutil.log('Gulp is running!') }); $ gulp

The default task will run and show you the “Gulp is running!” message.

To run individual tasks, use gulp .

So this is it, you are good to go. You have your basic infrastructure ready now and you can implement as much tasks as per your needs.

We’ve just scratched the surface of GULP. In the future blog post of this series we’ll be coveringthe advanced section. So,stay tuned till then. Love and Peace.


Implementation of Gulp.js from Scratch

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

主题: GulpNode.jsSAS
分页:12
转载请注明
本文标题:Implementation of Gulp.js from Scratch
本站链接:http://www.codesec.net/view/481767.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(27)