client/gulpfile.js
author cavaliet
Tue, 14 Oct 2014 12:35:22 +0200
changeset 19 3b70b46e8044
parent 13 435d5c15275a
child 22 986ee928a866
permissions -rw-r--r--
piano roll with visual specifications
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     1
var gulp = require('gulp');
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     2
var del = require('del');
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     3
var gutil = require('gulp-util')
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     4
var plugins = require("gulp-load-plugins")({lazy:false});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     5
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
     6
var templateFolder = '../annot-server/templates/';
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
     7
var templateFileDest = '../annot-server/templates/annotationclient.html';
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
     8
var staticFolder = '../annot-server/static';
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
     9
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
var clientBaseName = 'app';
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    11
var vendorBaseName = 'lib';
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    12
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    13
gulp.task('clean', function (cb) {
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    14
    del([
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    15
        templateFileDest,
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    16
        staticFolder + "/css/app*",
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    17
        staticFolder + "/js/app*",
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    18
        staticFolder + "/data/categories.json",
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    19
    ],{'force':true}, cb);
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    20
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    21
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    22
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js'];
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    23
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    24
gulp.task('scripts', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    25
    //combine all js files of the app
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    26
    gulp.src(scriptsSrc)
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    27
        .pipe(plugins.jshint())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    28
        .pipe(plugins.jshint.reporter('default'))
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    29
        .pipe(plugins.jshint.reporter('fail'))
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    30
        .pipe(plugins.concat(clientBaseName+'.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    31
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    32
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    33
        .pipe(plugins.uglify())
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    34
        .pipe(plugins.rename(clientBaseName+'.min.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    35
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    36
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    37
        .on('error', gutil.log);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    38
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    39
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    40
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    41
gulp.task('css', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    42
    gulp.src('./app/**/*.css')
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    43
        .pipe(plugins.csslint({ 'box-sizing': false }))
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    44
        .pipe(plugins.csslint.reporter())
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    45
        .pipe(plugins.concat(clientBaseName+'.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    46
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    47
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    48
        .pipe(plugins.minifyCss({keepBreaks:true}))
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    49
        .pipe(plugins.rename(clientBaseName+'.min.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    50
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    51
        .pipe(plugins.filesize());
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    52
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    53
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    54
var vendorJSsrc = [
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    55
  '!./bower_components/**/*.min.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    56
  '!./bower_components/bootstrap/Gruntfile.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    57
  '!./bower_components/bootstrap/grunt/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    58
  '!./bower_components/bootstrap/js/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    59
  '!./bower_components/jquery/src/**/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    60
  '!./bower_components/angular-bootstrap/ui-bootstrap.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    61
  './bower_components/jquery/dist/jquery.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    62
  './bower_components/**/*.js'
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    63
];
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    64
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    65
gulp.task('vendorJS', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    66
    //concatenate vendor JS files
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    67
    gulp.src(vendorJSsrc)
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    68
        .pipe(plugins.concat('lib.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    69
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    70
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    71
        .pipe(plugins.uglify())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    72
        .pipe(plugins.rename('lib.min.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    73
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    74
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    75
        .on('error', gutil.log);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    76
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    77
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    78
gulp.task('vendorCSS', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    79
    //concatenate vendor CSS files
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    80
    gulp.src(['!./bower_components/**/*.min.css',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    81
        './bower_components/**/*.css'])
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    82
        .pipe(plugins.concat(vendorBaseName+'.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    83
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    84
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    85
        .pipe(plugins.minifyCss({keepBreaks:true}))
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    86
        .pipe(plugins.rename(vendorBaseName+'.min.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    87
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    88
        .pipe(plugins.filesize());
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    89
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    90
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    91
gulp.task('vendorFonts', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    92
    gulp.src(['./bower_components/**/fonts/*'])
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    93
        .pipe(plugins.flatten())
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    94
        .pipe(gulp.dest(staticFolder+'/css/fonts'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    95
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    96
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    97
gulp.task('copy-index', function() {
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    98
    gulp.src('./app/annotationclient.html')
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    99
        .pipe(gulp.dest(templateFolder));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   100
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   101
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   102
gulp.task('copy-data', function() {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   103
    gulp.src('./data/**/*')
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   104
        .pipe(gulp.dest(staticFolder+'/data'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   105
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   106
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   107
gulp.task('copy-img', function() {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   108
    gulp.src('./img/**/*')
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   109
        .pipe(gulp.dest(staticFolder+'/img'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   110
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   111
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   112
gulp.task('watch',function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   113
    gulp.watch([
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   114
        templateFolder+'/**/*.html',
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   115
        staticFolder+'/**/*.js',
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   116
        staticFolder+'/**/*.css'
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   117
    ], function(event) {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   118
        return gulp.src(event.path)
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   119
            .pipe(plugins.webserver.reload());
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   120
    });
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   121
    gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   122
    gulp.watch('./app/**/*.css',['css']);
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   123
    gulp.watch('./app/annotationclient.html',['copy-index']);
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   124
    gulp.watch('./data/**/*',['copy-data']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   125
    gulp.watch('./img/**/*',['copy-img']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   126
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   127
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   128
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   129
gulp.task('connect', function() {
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   130
    gulp.src('build').pipe(
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   131
        plugins.webserver({
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   132
            port: 9000,
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   133
            livereload: true
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   134
        })
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   135
    );
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   136
});
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   137
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   138
gulp.task('default',['scripts','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts']);