![Oracle JET for Developers](https://wfqqreader-1252317822.image.myqcloud.com/cover/421/36700421/b_36700421.jpg)
上QQ阅读APP看书,第一时间看更新
Installing Gulp
Gulp can be installed based on npm using the following command:
npm install --global gulp-cli
Once the Gulp installation is complete, a gulpfile.js configuration file should be generated in the project's Important Files folder in NetBeans IDE with its syntax looking like the following:
var gulp = require('gulp');
gulp.task('default', function() {
// place code for your default task here
});
Gulp can be executed as part of the command line using the gulp command, or made part of the NetBeans IDE commands as follows:
- The Gulp executable can be configured in NetBeans IDE by selecting Tools | Options and choosing the HTML/JS and Gulp options:
![](https://epubservercos.yuewen.com/D7C5E9/19470400108919206/epubprivate/OEBPS/Images/Chapter_141.jpg?sign=1739155403-gmhh8g7ov5LrU3Xj4rncnRMwypMd4xfT-0-424d7fb72431afa9f685775f75397eb4)
- The following is the project structure once gulpfile.js is added:
![](https://epubservercos.yuewen.com/D7C5E9/19470400108919206/epubprivate/OEBPS/Images/Chapter_117.jpg?sign=1739155403-cIm6mYe3v1suNq8gTV2IcjhVNqn9D40X-0-d4b2631d48dfda97ce03721ee1b5ea21)
- Gulp tasks (clean, build, run, debug, and test both project and file, as highlighted in the following screenshot) can be assigned to common IDE actions by right-clicking on the project and selecting the Project Properties and Gulp options:
![](https://epubservercos.yuewen.com/D7C5E9/19470400108919206/epubprivate/OEBPS/Images/Chapter_122.jpg?sign=1739155403-zufMlgLL8stlvCE4JGm2KcyFux05VwOM-0-b3a4582c0df8a773a39adb6459c704a6)
- Gulp tasks can be run via the project's context menu by right-clicking on the project as follows:
![](https://epubservercos.yuewen.com/D7C5E9/19470400108919206/epubprivate/OEBPS/Images/Chapter_147.jpg?sign=1739155403-aRSbC6EsXSvu09CEQzQGIYWdRl3LsyH3-0-e7f1e39423f01489ebb3a43fd7b52635)
- We can also set the parameters, if needed, as follows:
![](https://epubservercos.yuewen.com/D7C5E9/19470400108919206/epubprivate/OEBPS/Images/Chapter_136.jpg?sign=1739155403-P1wGVkKiyhp0KpyD62XcqwknfAE6drn1-0-b527bc06a8c24d1d7307236ced89fd30)
- We can right-click on the project, select Gulp Tasks, and click the saved advanced option to invoke the target to execute as follows:
![](https://epubservercos.yuewen.com/D7C5E9/19470400108919206/epubprivate/OEBPS/Images/Chapter_30.jpg?sign=1739155403-kRzTcvn5Xk6Wmi7S5inkiCuO9cXGhn7J-0-f3cc1d809537b45562c4a3dd8996c7e2)
- Gulp output can be reviewed in the output window as the script is executed:
![](https://epubservercos.yuewen.com/D7C5E9/19470400108919206/epubprivate/OEBPS/Images/Chapter_158.jpg?sign=1739155403-FqvwWyKwUBEwNuKqgI17Y1E8OgLBifHl-0-64aadffef9d8e480beb58c687ce2a87d)
Gulp can be used in projects to help us save a lot of effort in repetitive tasks such as code optimization, minifying, programmatic testing, CSS preprocessing, and deploying to the targeted environment.