author | ymh <ymh.work@gmail.com> |
Mon, 19 Jan 2015 13:31:28 +0100 | |
changeset 95 | 806739a26858 |
parent 81 | a6bbf198bd24 |
child 158 | c7e0e3212b4c |
permissions | -rw-r--r-- |
1 | 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 | 3 |
var gutil = require('gulp-util') |
4 |
var plugins = require("gulp-load-plugins")({lazy:false}); |
|
5 |
||
81 | 6 |
var templateFolder = '../../annot-server/webapp/templates/'; |
7 |
var staticFolder = '../../annot-server/static'; |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
8 |
|
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
|
9 |
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
|
10 |
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
|
11 |
|
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 |
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
|
13 |
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
|
14 |
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
|
15 |
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
|
16 |
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
|
17 |
],{'force':true}, cb); |
1 | 18 |
}); |
19 |
||
20 |
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js']; |
|
21 |
||
22 |
gulp.task('scripts', function(){ |
|
23 |
//combine all js files of the app |
|
24 |
gulp.src(scriptsSrc) |
|
25 |
.pipe(plugins.jshint()) |
|
26 |
.pipe(plugins.jshint.reporter('default')) |
|
27 |
.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
|
28 |
.pipe(plugins.concat(clientBaseName+'.js')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
29 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 30 |
.pipe(plugins.filesize()) |
31 |
.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
|
32 |
.pipe(plugins.rename(clientBaseName+'.min.js')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
33 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 34 |
.pipe(plugins.filesize()) |
35 |
.on('error', gutil.log); |
|
36 |
}); |
|
37 |
||
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
38 |
|
1 | 39 |
gulp.task('css', function(){ |
40 |
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
|
41 |
.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
|
42 |
.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
|
43 |
.pipe(plugins.concat(clientBaseName+'.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
44 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 45 |
.pipe(plugins.filesize()) |
46 |
.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
|
47 |
.pipe(plugins.rename(clientBaseName+'.min.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
48 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 49 |
.pipe(plugins.filesize()); |
50 |
}); |
|
51 |
||
52 |
var vendorJSsrc = [ |
|
53 |
'!./bower_components/**/*.min.js', |
|
54 |
'!./bower_components/bootstrap/Gruntfile.js', |
|
55 |
'!./bower_components/bootstrap/grunt/*', |
|
56 |
'!./bower_components/bootstrap/js/*', |
|
57 |
'!./bower_components/jquery/src/**/*', |
|
58 |
'!./bower_components/angular-bootstrap/ui-bootstrap.js', |
|
59 |
'./bower_components/jquery/dist/jquery.js', |
|
66
658561ea9e65
export sync code in utils, and add button to synchronize annotation on eventsessionview
ymh <ymh.work@gmail.com>
parents:
22
diff
changeset
|
60 |
'./bower_components/angular/angular.js', |
1 | 61 |
'./bower_components/**/*.js' |
62 |
]; |
|
63 |
||
64 |
gulp.task('vendorJS', function(){ |
|
65 |
//concatenate vendor JS files |
|
66 |
gulp.src(vendorJSsrc) |
|
67 |
.pipe(plugins.concat('lib.js')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
68 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 69 |
.pipe(plugins.filesize()) |
70 |
.pipe(plugins.uglify()) |
|
71 |
.pipe(plugins.rename('lib.min.js')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
72 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 73 |
.pipe(plugins.filesize()) |
74 |
.on('error', gutil.log); |
|
75 |
}); |
|
76 |
||
77 |
gulp.task('vendorCSS', function(){ |
|
78 |
//concatenate vendor CSS files |
|
79 |
gulp.src(['!./bower_components/**/*.min.css', |
|
80 |
'./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
|
81 |
.pipe(plugins.concat(vendorBaseName+'.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
82 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 83 |
.pipe(plugins.filesize()) |
84 |
.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
|
85 |
.pipe(plugins.rename(vendorBaseName+'.min.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
86 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 87 |
.pipe(plugins.filesize()); |
88 |
}); |
|
89 |
||
90 |
gulp.task('vendorFonts', function(){ |
|
91 |
gulp.src(['./bower_components/**/fonts/*']) |
|
92 |
.pipe(plugins.flatten()) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
93 |
.pipe(gulp.dest(staticFolder+'/css/fonts')); |
1 | 94 |
}); |
95 |
||
96 |
gulp.task('copy-index', function() { |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
97 |
gulp.src('./app/annotationclient.html') |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
98 |
.pipe(gulp.dest(templateFolder)); |
1 | 99 |
}); |
100 |
||
101 |
gulp.task('copy-data', function() { |
|
102 |
gulp.src('./data/**/*') |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
103 |
.pipe(gulp.dest(staticFolder+'/data')); |
1 | 104 |
}); |
105 |
||
106 |
gulp.task('copy-img', function() { |
|
107 |
gulp.src('./img/**/*') |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
108 |
.pipe(gulp.dest(staticFolder+'/img')); |
1 | 109 |
}); |
110 |
||
111 |
gulp.task('watch',function(){ |
|
112 |
gulp.watch([ |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
113 |
templateFolder+'/**/*.html', |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
114 |
staticFolder+'/**/*.js', |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
115 |
staticFolder+'/**/*.css' |
1 | 116 |
], function(event) { |
117 |
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
|
118 |
.pipe(plugins.webserver.reload()); |
1 | 119 |
}); |
120 |
gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']); |
|
121 |
gulp.watch('./app/**/*.css',['css']); |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
122 |
gulp.watch('./app/annotationclient.html',['copy-index']); |
1 | 123 |
gulp.watch('./data/**/*',['copy-data']); |
124 |
gulp.watch('./img/**/*',['copy-img']); |
|
125 |
||
126 |
}); |
|
127 |
||
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
|
128 |
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
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
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
|
133 |
}) |
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 |
}); |
1 | 136 |
|
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
|
137 |
gulp.task('default',['scripts','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts']); |