author | cavaliet |
Thu, 09 Oct 2014 14:34:14 +0200 | |
changeset 5 | 90a7c431b979 |
parent 4 | 9c70d81e9062 |
child 13 | 435d5c15275a |
permissions | -rw-r--r-- |
1 | 1 |
var gulp = require('gulp'); |
2 |
var gutil = require('gulp-util') |
|
3 |
var plugins = require("gulp-load-plugins")({lazy:false}); |
|
4 |
//var flatten = require('gulp-flatten'); |
|
5 |
//var uglify = require('gulp-uglify'); |
|
6 |
//var clean = require('gulp-clean'); |
|
7 |
//var rename = require('gulp-rename'); |
|
8 |
//var filesize = require('gulp-filesize'); |
|
9 |
//var cssmin = require('gulp-cssmin'); |
|
10 |
||
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
11 |
var templateFolder = '../annot-server/templates/'; |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
12 |
var templateFileDest = '../annot-server/templates/annotationclient.html'; |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
13 |
var staticFolder = '../annot-server/static'; |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
14 |
|
1 | 15 |
gulp.task('clean', function () { |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
16 |
gulp.src(templateFileDest, {read: false}).pipe(clean()); |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
17 |
gulp.src(staticFolder, {read: false}).pipe(clean()); |
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')) |
|
28 |
.pipe(plugins.concat('app.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()) |
|
32 |
.pipe(plugins.rename('app.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 |
|
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
39 |
//gulp.task('templates',function(){ |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
40 |
// //combine all template files of the app into a js file |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
41 |
// gulp.src(['!./app/index.html', |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
42 |
// './app/**/*.html']) |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
43 |
// .pipe(plugins.angularTemplatecache('templates.js',{standalone:true})) |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
44 |
// .pipe(gulp.dest(staticFolder+'/js')); |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
45 |
//}); |
1 | 46 |
|
47 |
gulp.task('css', function(){ |
|
48 |
gulp.src('./app/**/*.css') |
|
49 |
// .pipe(plugins.csslint()) |
|
50 |
// .pipe(plugins.csslint.reporter()) |
|
51 |
.pipe(plugins.concat('app.css')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
52 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 53 |
.pipe(plugins.filesize()) |
54 |
.pipe(plugins.minifyCss({keepBreaks:true})) |
|
55 |
.pipe(plugins.rename('app.min.css')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
56 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 57 |
.pipe(plugins.filesize()); |
58 |
}); |
|
59 |
||
60 |
var vendorJSsrc = [ |
|
61 |
'!./bower_components/**/*.min.js', |
|
62 |
'!./bower_components/bootstrap/Gruntfile.js', |
|
63 |
'!./bower_components/bootstrap/grunt/*', |
|
64 |
'!./bower_components/bootstrap/js/*', |
|
65 |
'!./bower_components/jquery/src/**/*', |
|
66 |
'!./bower_components/angular-bootstrap/ui-bootstrap.js', |
|
67 |
'./bower_components/jquery/dist/jquery.js', |
|
68 |
'./bower_components/**/*.js' |
|
69 |
]; |
|
70 |
||
71 |
gulp.task('vendorJS', function(){ |
|
72 |
//concatenate vendor JS files |
|
73 |
gulp.src(vendorJSsrc) |
|
74 |
.pipe(plugins.concat('lib.js')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
75 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 76 |
.pipe(plugins.filesize()) |
77 |
.pipe(plugins.uglify()) |
|
78 |
.pipe(plugins.rename('lib.min.js')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
79 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 80 |
.pipe(plugins.filesize()) |
81 |
.on('error', gutil.log); |
|
82 |
}); |
|
83 |
||
84 |
gulp.task('vendorCSS', function(){ |
|
85 |
//concatenate vendor CSS files |
|
86 |
gulp.src(['!./bower_components/**/*.min.css', |
|
87 |
'./bower_components/**/*.css']) |
|
88 |
.pipe(plugins.concat('lib.css')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
89 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 90 |
.pipe(plugins.filesize()) |
91 |
.pipe(plugins.minifyCss({keepBreaks:true})) |
|
92 |
.pipe(plugins.rename('lib.min.css')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
93 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 94 |
.pipe(plugins.filesize()); |
95 |
}); |
|
96 |
||
97 |
gulp.task('vendorFonts', function(){ |
|
98 |
gulp.src(['./bower_components/**/fonts/*']) |
|
99 |
.pipe(plugins.flatten()) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
100 |
.pipe(gulp.dest(staticFolder+'/css/fonts')); |
1 | 101 |
}); |
102 |
||
103 |
gulp.task('copy-index', function() { |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
104 |
gulp.src('./app/annotationclient.html') |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
105 |
.pipe(gulp.dest(templateFolder)); |
1 | 106 |
}); |
107 |
||
108 |
gulp.task('copy-data', function() { |
|
109 |
gulp.src('./data/**/*') |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
110 |
.pipe(gulp.dest(staticFolder+'/data')); |
1 | 111 |
}); |
112 |
||
113 |
gulp.task('copy-img', function() { |
|
114 |
gulp.src('./img/**/*') |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
115 |
.pipe(gulp.dest(staticFolder+'/img')); |
1 | 116 |
}); |
117 |
||
118 |
gulp.task('watch',function(){ |
|
119 |
gulp.watch([ |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
120 |
templateFolder+'/**/*.html', |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
121 |
staticFolder+'/**/*.js', |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
122 |
staticFolder+'/**/*.css' |
1 | 123 |
], function(event) { |
124 |
return gulp.src(event.path) |
|
125 |
.pipe(plugins.connect.reload()); |
|
126 |
}); |
|
127 |
gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']); |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
128 |
//gulp.watch(['!./app/index.html','./app/**/*.html'],['templates']); |
1 | 129 |
gulp.watch('./app/**/*.css',['css']); |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
130 |
gulp.watch('./app/annotationclient.html',['copy-index']); |
1 | 131 |
gulp.watch('./data/**/*',['copy-data']); |
132 |
gulp.watch('./img/**/*',['copy-img']); |
|
133 |
||
134 |
}); |
|
135 |
||
136 |
gulp.task('connect', plugins.connect.server({ |
|
137 |
root: ['build'], |
|
138 |
port: 9000, |
|
139 |
livereload: true |
|
140 |
})); |
|
141 |
||
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
142 |
//gulp.task('default',['connect','scripts','templates','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']); |
5
90a7c431b979
first step of working annotation real annotation client
cavaliet
parents:
4
diff
changeset
|
143 |
gulp.task('default',['scripts','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']); |