Google News
logo
Gulp - Interview Questions
How would you go about setting up a Gulp project from scratch?
To set up a Gulp project from scratch, first install Node.js and npm. Then, globally install Gulp using the command ‘npm install gulp -g’. Create a new directory for your project and navigate into it. Initialize a new npm project with ‘npm init’ and follow the prompts to create a package.json file. Install Gulp locally in your project using ‘npm install gulp –save-dev, which adds Gulp as a devDependency in your package.json file.

Next, create a Gulpfile.js at the root of your project. This is where you’ll define tasks. Start by requiring Gulp at the top of this file with ‘const gulp = require(‘gulp’);’. Now, you can start defining tasks. For example, to define a default task that logs ‘Hello, World!’, write:
gulp.task('default', function() {
  console.log('Hello, World!');
});​

Run this task using ‘gulp’ in your terminal.
Advertisement