aboutsummaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
authorIndrajith K L2018-08-14 11:05:32 +0530
committerIndrajith K L2018-08-14 11:05:32 +0530
commitecc12b2ef3b058ddd8bf9612afd7c9276f0386f9 (patch)
tree7eeeaa2644740920c07b7cfbc77d2a84eb68bf83 /gulpfile.js
parente1f9fdc2c83d0b15286aeb8f39be34e8612e2ec3 (diff)
downloadjs13kgames-template-ecc12b2ef3b058ddd8bf9612afd7c9276f0386f9.tar.gz
js13kgames-template-ecc12b2ef3b058ddd8bf9612afd7c9276f0386f9.tar.bz2
js13kgames-template-ecc12b2ef3b058ddd8bf9612afd7c9276f0386f9.zip
* removed unwanted dependencies
* improved compression * Introduces Audio Player :sparkles: :fire: :racehorse: :snowflake: :gem:
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js52
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
+ });
});