Run Gulp.js from eclipse

Overview

This post provides details on how run gulp.js in eclipse.

Pre-requisites:

  • Install node on Local machine.
  • Install node eclipse plugin as described here.
  • Download required node modules to get the required libraries as described here.

Steps to execute Gulp.js:

  • Create gulp.js file with required tasks.
  • Create build.js file with trigger to gulp.js file.
  • Right click on build.js file and run it as Node Application.
  • In order to trigger specific gulp tasks, trigger them via program arguments to build.js.
Find below the snippet of the gulp.js, you can find complete gulp.js here.
var gulp = require('gulp');

:::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::

gulp.task('default', ['build']);

gulp.task('clean', function () {
:::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::
});
   
Find below the snippet of the build.js, you can find complete build.js here.
var gulp = require('gulp');
require('./gulp.js');

if(process.argv[2] == 'clean'){
	gulp.start('clean');
} else if (process.argv[2] == 'output') {
	gulp.start('output');
}else if (process.argv[2] == 'minifiedoutput') {
	gulp.start('minoutput');
} else {
	gulp.start('build');
}
   

Also Read:

Advertisements

Download Node modules in Eclipse work space

Overview

This post provides details on how the node modules can be downloaded into Eclipse workspace.

Pre-requisites:

  • Install node eclipse on Local machine.
  • Install node eclipse plugin as described here.

Node Modules download steps:

  • Create package.json file.
  • List out the modules to be downloaded as dependencies.
  • Right click on package.json and run as npm install.
  • All the required modules will be downloaded to Eclipse workspace.
   {
   "name": "demo-eclipse",
   "version": "0.0.1",
   "private": true,
   "dependencies":{
	   "gulp":"3.9.0",
	   "del":"*",
	   "gulp-babel":"*",
	   "babel-preset-es2015":"*",
	   "babel-preset-react":"*",
	   "babel-plugin-transform-object-rest-spread":"*",
	   "browserify":"*",
	   "gulp-uglify":"*",
	   "vinyl-source-stream":"*",
	   "gulp-streamify":"*",
	   "react":"*",
	   "fixed-data-table":"*",
	   "faker":"*",
	   "react-dom":"*"   
    }
   }   
   
Refer Node Modules screenshot below:
nodeModules

 

 

 

Also Read:

Basic NodeEclipse Setup

Overview

Eclipse is an IDE which is built in java and is mostly used for java development. Eclipse also supports multiple other languages through use of plugins.
Eclipse has some of the javascript plugins which aid in javascript development.
In recent years node.js has become one of the major platform for building javascript applications. NodeEclipse is an Eclipse plugin for node.js.

NodeEclipse Installation:

  • Install node js on Local machine.
  • Click Eclipse Help -> Eclipse Market place.
  • Type Node under Find and Click GO.
  • In the displayed list select NodeEclipse and click Update/Install.
  • Select the relevant packages and click Next and finally install.

Configuring NodeEclipse:

On successful installation of Node Eclipse, we need to configure it via Eclipse -> Window -> Preferences

  • Under preferences we see NodeEclipse.
  • On click of NodeEclipse, we have all the configuration details for Node.js running used from eclipse.
  • Revalidate Node.js path and click OK.

Conclusion:

After above setup, Node.js based programming can be used from eclipse itself.