Java Reference
In-Depth Information
If you want to pass the project to another developer, just ensure that the
package.json file is included. The developer could then install all project de-
pendencies using:
$ npm install
The main JavaScript files that are written in development should be moved into a new
folder named src. The Gulp task will take the JavaScript file in this folder and pipe them
through the stripdebug and uglify plugins before saving the output in the js folder.
We now need to create the Gulp file that will run the task. Create a file called gulpfile.js
that contains the following lines of code and save it in the same directory as index.htm:
var
gulp = require('gulp'),
stripdebug = require('gulp-strip-debug'),
uglify = require('gulp-uglify');
var
source = 'src/*',
dest = 'js/';
// strip debugging and minify JS
gulp.task('js', function() {
return gulp.src(source)
.pipe(stripdebug())
.pipe(uglify())
.pipe(gulp.dest(dest));
});
// default task
gulp.task('default', ['js'], function() {
// watch for javascript changes
gulp.watch(source, ['js']);
});
Search WWH ::




Custom Search