<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ashishmangla0</title>
    <description>The latest articles on DEV Community by ashishmangla0 (@ashishmangla0).</description>
    <link>https://dev.to/ashishmangla0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F10592%2F24789070.png</url>
      <title>DEV Community: ashishmangla0</title>
      <link>https://dev.to/ashishmangla0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashishmangla0"/>
    <language>en</language>
    <item>
      <title>How to setup Gulp with ES6</title>
      <dc:creator>ashishmangla0</dc:creator>
      <pubDate>Sun, 14 Aug 2022 10:46:00 +0000</pubDate>
      <link>https://dev.to/ashishmangla0/how-to-setup-gulp-with-es6-2i7d</link>
      <guid>https://dev.to/ashishmangla0/how-to-setup-gulp-with-es6-2i7d</guid>
      <description>&lt;p&gt;&lt;a href="https://gulpjs.com/"&gt;Gulp&lt;/a&gt; is a tool that runs on &lt;a href="https://nodejs.org/en/"&gt;Node.js&lt;/a&gt; which helps us automate many development tasks, we can use it for automating slow and repetitive work.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Gulp works
&lt;/h2&gt;

&lt;p&gt;Gulp reads files as streams and pipes those streams to different tasks. These tasks are code-based and use plugins in order to build production files from source files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/download/"&gt;Node.js&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/"&gt;npm&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to install Gulp
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Install the gulp command line
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --global gulp-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a new project directory and navigate into it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx mkdirp my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a package.json file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install the gulp in your devDependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev gulp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Transpilation
&lt;/h3&gt;

&lt;p&gt;we have to rename our gulpfile extention &lt;code&gt;gulpfile.js&lt;/code&gt; to &lt;code&gt;gulpfile.babel.js&lt;/code&gt; for Babel transpilation and have to install the &lt;a href="https://www.npmjs.com/package/@babel/register"&gt;@babel/register module&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How To Create Tasks in Gulp
&lt;/h3&gt;

&lt;p&gt;Gulp gives two composition methods &lt;code&gt;series()&lt;/code&gt; and &lt;code&gt;parallel()&lt;/code&gt; ,Both Methods takes n numbers of task functions or composed operations. this two methods can be nested within themselves or each other to any depth.&lt;/p&gt;

&lt;h4&gt;
  
  
  Tasks in series() method
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;series()&lt;/code&gt; method is used when you we have to run tasks in order.&lt;/p&gt;

&lt;h5&gt;
  
  
  Example
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { series } from "gulp";
const funA = (cd) =&amp;gt;{
cb();
}
const funB = (cd) =&amp;gt;{
cb();
}
export default series(funA ,funB)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Tasks in parallel() method
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;parallel()&lt;/code&gt; method is used when you we have to run tasks in concurrency.&lt;/p&gt;

&lt;h5&gt;
  
  
  Example
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { parallel } from "gulp";
const javascript = (cd) =&amp;gt;{
cb();
}
const css = (cd) =&amp;gt;{
cb();
}
export default parallel(javascript ,css)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>taskrunner</category>
      <category>gulp</category>
    </item>
  </channel>
</rss>
