Content deleted Content added
Visaldatta (talk | contribs) No edit summary |
Visaldatta (talk | contribs) editing the space issues |
||
Line 21:
== == Gulpfile.js
In the first step all the modules must be defined in the gulpfile.js. <syntaxhighlight lang="javascript">
//
var gulp = require ( 'gulp');
var gutil = require ( 'util-gulp');
Line 27:
In the next step, the tasks can then be created. A gulp task is defined by ''gulp.task'' and gets a name for the task as the first parameter and the second parameter is a function.
The following example shows the creation of a gulp tasks. The first parameter '' taskName '' is mandatory and specifies the name by which the task in the shell can be executed <ref> {{Internet source | url = https://github.com/gulpjs/gulp/blob/
gulp.task ( 'taskName', function () {
//
});
</syntaxhighlight>
Line 56:
=== === Image Task
For the following example, the '' gulp-imagemin plugin '' <ref>[https://www.npmjs.com/package/gulp-imagemin/
Subsequently, the module must be at the beginning of '' gulpfile.js 'defined': <syntaxhighlight lang= "javascript">
Line 62:
</syntaxhighlight>
The subsequent image Task performs optimizing images. <Code> gulp.src () </code> retrieves all the images with the extension .png, .gif or .jpg in the directory '' <nowiki/> 'images-orig
// Images task
gulp.task ( 'images', function () {
gulp.src ( 'images-orig
.pipe (imagemin ())
.pipe (gulp.dest ( 'images
});
Line 73:
=== === Scripts Task
In the following example, all JavaScript files from the directory '' <nowiki/> 'scripts
//
gulp.task ( 'scripts', function () {
gulp.src ( 'scripts
.pipe (uglify ())
.pipe (gulp.dest ( 'scripts
});
</syntaxhighlight>
Line 86:
// Rerun the task When a file changes
gulp.task ( 'watch', function () {
gulp.watch ( '. scripts
gulp.watch ( 'images-orig
});
</syntaxhighlight>
Furthermore, it is possible to accomplish an update of the browser content using the Watch-tasks <ref> {{Internet source | url = https://www.browsersync.io/docs/gulp/
== Literature ==
Line 100:
== Links ==
* [Http://gulpjs.com/
* [Https://github.com/gulpjs/gulp/
* [Https://css-tricks.com/gulp-for-beginners/
* [Https://www.browsersync.io/docs/gulp/
== References ==
|