This guide explains how to set up Node.js and Gulp on your computer and how to use the provided Gulp file for development tasks. Follow the steps below to get started.
Prerequisites
Before you start, ensure the following:
- Node.js and npm: Installed on your computer.
- Command Line Interface (CLI): Such as Command Prompt, Terminal, or PowerShell.
- Gulp file: The provided
gulpfile.js
is in the project root directory.
Step 1: Install Node.js and npm
- Download the latest LTS version of Node.js from Node.js official website.
- Run the installer and follow the prompts.
- Verify the installation:
- Open your CLI.
- Run
node -v
to check the Node.js version. - Run
npm -v
to check the npm version.
Step 2: Install Gulp CLI Globally
- Run the following command in your CLI to install Gulp globally:
npm install --global gulp-cli
- Verify the installation by running:
gulp --version
This should display the installed Gulp version.
Step 3: Set Up the Project
- Navigate to the project directory where the
gulpfile.js
is located:cd /path/to/your/project
- Install the project dependencies by running:
npm install
This will install all dependencies listed in thepackage.json
file.
Step 4: Running Gulp Tasks
Local Development
- To start the development environment with live reloading:
gulp --local
- This will:
- Compile SCSS files into minified CSS.
- Transpile and minify JavaScript files.
- Start a BrowserSync server for live reloading.
Individual Tasks
- Compile Styles:
gulp styles
Processes thescss/main.scss
file intodist/main.min.css
. - Compile Admin Styles:
gulp admin_styles
Processes thescss/admin/admin.scss
file intodist/admin.min.css
. - Compile Scripts:
gulp scripts
Transpiles and minifies JavaScript files intodist/main.min.js
. - Watch for Changes:
gulp watch
Automatically runs tasks when source files are updated.