From ddbf11efa3667f6db0f04e93e6ce8ddc17b73a52 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sun, 12 Aug 2018 02:37:22 +0530 Subject: Initial Commmit: Gulp Tasks for * Copy libs to public folder * Source Uglyfy + Copy * Zip --- gulpfile.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 gulpfile.js (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..68c26f3 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,56 @@ +'use strict'; + +var gulp = require('gulp'); +var browserSync = require('browser-sync').create(); +var uglify = require('gulp-uglify'); +const zip = require('gulp-vinyl-zip').zip; +var size = require('gulp-size'); + +var libs = ['./node_modules/kontra/kontra.min.js', './node_modules/tinymusic/dist/TinyMusic.min.js']; +var libFolder = 'libs/'; +var outputTemp = 'temp/'; + +gulp.task('serve', ['copylibs'], function () { + + browserSync.init({ + server: './' + }); + + gulp.watch("./**/*.js", { cwd: './' },function(){ + gulp.run('uglyfy_copy') + }).on('change', browserSync.reload);; + gulp.watch("./**/*.html", { cwd: './' }).on('change', browserSync.reload); + + browserSync.watch() + +}); + +gulp.task('uglyfy_copy', function () { + return gulp.src('src/js/*.js') + .pipe(uglify()) + .pipe(gulp.dest('public/js')); + +}); + + +gulp.task('copylibs', function () { + return gulp + .src(libs) + .pipe(gulp.dest(libFolder)) +}); + +gulp.task('zipFiles',['prepare_dist_folder'], function () { + return gulp.src('temp/**/*.*') + .pipe(zip('archive.zip')) + .pipe(gulp.dest('dist')) + .pipe(size({ + title: '### Final Archive Size => ' + })) + +}); + +gulp.task('prepare_dist_folder', function () { + return gulp + .src(['libs/*','public/**/*.*','index.html'],{base: './'}) + .pipe(gulp.dest(outputTemp)) +}); -- cgit v1.2.3