aboutsummaryrefslogtreecommitdiff
path: root/gulpfile.js
blob: 68c26f3477b275714f127044a2372582eb791c2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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))
});