From ecc12b2ef3b058ddd8bf9612afd7c9276f0386f9 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Tue, 14 Aug 2018 11:05:32 +0530 Subject: * removed unwanted dependencies * improved compression * Introduces Audio Player :sparkles: :fire: :racehorse: :snowflake: :gem: --- gulpfile.js | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 2fc8d42..f474ff0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,24 +6,24 @@ const uglify = require('gulp-uglify'); const zip = require('gulp-vinyl-zip').zip; const size = require('gulp-size'); const runSequence = require('run-sequence'); -const rollup = require('rollup-stream'); +const rlup = require('rollup'); const del = require('del'); +const babel = require('rollup-plugin-babel'); +const terser = require('rollup-plugin-terser'); - -const source = require('vinyl-source-stream'); const libs = ['./node_modules/kontra/kontra.min.js', './node_modules/tinymusic/dist/TinyMusic.min.js']; const devLibs = ['./node_modules/jsfxr/jsfxr.js']; const libFolder = 'libs/'; const outputTemp = 'temp/'; -gulp.task('serve', ['copylibs', 'copylibsDev', 'uglyfy_copy'], function () { +gulp.task('serve', ['copylibs', 'copylibsDev', 'transpile'], function () { browserSync.init({ server: { baseDir: "./" } }); - gulp.watch("src/js/**/*.js", { cwd: './' }, ['uglyfy_copy', 'reload']) + gulp.watch("src/js/**/*.js", { cwd: './' }, ['transpile', 'reload']) gulp.watch("./**/*.html", { cwd: './' }).on('change', browserSync.reload); browserSync.watch() @@ -34,23 +34,18 @@ gulp.task('reload', function () { browserSync.reload(); }); -gulp.task('delete_folders', function(){ - return del(['libs/','public/','temp/','dist/']).then(function(paths){ - console.log('Deleted Files & folders ',paths); +gulp.task('delete_folders', function () { + return del(['libs/', 'public/', 'temp/', 'dist/']).then(function (paths) { + console.log('Deleted Files & folders ', paths); }); }); -gulp.task('uglyfy_copy', function () { - return rollup({ - "format": "iife", - input: './src/js/main.js' - }) - .pipe(source('main.js')) - .pipe(gulp.dest('public/js')); +gulp.task('delete_map_files', function () { + return del(['temp/**/*.map']).then(function () { + }); }); - gulp.task('copylibs', function () { return gulp .src(libs) @@ -81,5 +76,28 @@ gulp.task('prepare_dist_folder', function () { }); gulp.task('release', function () { - runSequence('delete_folders','copylibs', 'copylibsDev', 'uglyfy_copy', 'prepare_dist_folder', 'zipFiles'); + runSequence('delete_folders', 'copylibs', 'copylibsDev', 'transpile', 'prepare_dist_folder', 'delete_map_files', 'zipFiles'); +}); + +gulp.task('transpile', async function () { + + const bundle = await rlup.rollup({ + input: './src/js/main.js', + output: { + format: 'iife' + }, + plugins: [ + babel({ + exclude: 'node_modules/**' + }), + terser.terser() + ] + }); + + await bundle.write({ + file: './public/js/main.js', + format: 'umd', + name: 'library', + sourcemap: true + }); }); -- cgit v1.2.3