It is a toolkit used for automating tasks in your development workflow. It helps simplify and speed up processes like compiling code, minifying files, bundling, running tests, refreshing your browser, and many more.
Install Gulp and save it as a development dependency:
In terminal:
npm install --save-dev gulp
Now, Create a file named gulpfile.js in the root of your project.
const gulp = require('gulp');
// Example to demonstrate Gulp setup
gulp.task('default', function(done) {
console.log('Gulp is running!');
done();
});
We can also run Gulp from the command line, you can add a script in package.json:
{
"scripts": {
"gulp": "gulp"
}
}
Now, run Gulp tasks:
In Terminal:
npm run gulp.
A tool that bundle JavaScript files for the browser by managing dependencies using the CommonJS module format. It works by creating a single, large JavaScript file that includes all the modules and dependencies your application needs that can be run in the browser, making it easier to handle and maintain large JavaScript projects.
First, navigate to your project directory and install Browserify as a development dependency:
In terminal:
npm install browserify --save-dev
Browserify will bundle your React files. In your main React file : src/index.js.
In terminnal:
npx browserify src/index.js -o public/bundle.js
It will bundle all your JavaScript files (src/index.js).
To make the bundling process simpler, add a script to your package.json.
{
"scripts": {
"build": "browserify src/index.js -o public/bundle.js"
}
}
Now, run:
In terminal:
npm run build
Make sure the newly created bundle.js is included in your HTML file(public/index.html).
<script src="bundle.js"></script>
In terminal:
npm run watch
This will rebuild your bundle.js file whenever source files are modified.