diff options
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 52 |
1 files changed, 35 insertions, 17 deletions
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 + }); }); |