author | cavaliet |
Tue, 14 Oct 2014 12:35:22 +0200 | |
changeset 19 | 3b70b46e8044 |
parent 13 | 435d5c15275a |
child 22 | 986ee928a866 |
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 |
||
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 | 20 |
}); |
21 |
||
22 |
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js']; |
|
23 |
||
24 |
gulp.task('scripts', function(){ |
|
25 |
//combine all js files of the app |
|
26 |
gulp.src(scriptsSrc) |
|
27 |
.pipe(plugins.jshint()) |
|
28 |
.pipe(plugins.jshint.reporter('default')) |
|
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 | 32 |
.pipe(plugins.filesize()) |
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 | 36 |
.pipe(plugins.filesize()) |
37 |
.on('error', gutil.log); |
|
38 |
}); |
|
39 |
||
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
40 |
|
1 | 41 |
gulp.task('css', function(){ |
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 | 47 |
.pipe(plugins.filesize()) |
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 | 51 |
.pipe(plugins.filesize()); |
52 |
}); |
|
53 |
||
54 |
var vendorJSsrc = [ |
|
55 |
'!./bower_components/**/*.min.js', |
|
56 |
'!./bower_components/bootstrap/Gruntfile.js', |
|
57 |
'!./bower_components/bootstrap/grunt/*', |
|
58 |
'!./bower_components/bootstrap/js/*', |
|
59 |
'!./bower_components/jquery/src/**/*', |
|
60 |
'!./bower_components/angular-bootstrap/ui-bootstrap.js', |
|
61 |
'./bower_components/jquery/dist/jquery.js', |
|
62 |
'./bower_components/**/*.js' |
|
63 |
]; |
|
64 |
||
65 |
gulp.task('vendorJS', function(){ |
|
66 |
//concatenate vendor JS files |
|
67 |
gulp.src(vendorJSsrc) |
|
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 | 70 |
.pipe(plugins.filesize()) |
71 |
.pipe(plugins.uglify()) |
|
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 | 74 |
.pipe(plugins.filesize()) |
75 |
.on('error', gutil.log); |
|
76 |
}); |
|
77 |
||
78 |
gulp.task('vendorCSS', function(){ |
|
79 |
//concatenate vendor CSS files |
|
80 |
gulp.src(['!./bower_components/**/*.min.css', |
|
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 | 84 |
.pipe(plugins.filesize()) |
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 | 88 |
.pipe(plugins.filesize()); |
89 |
}); |
|
90 |
||
91 |
gulp.task('vendorFonts', function(){ |
|
92 |
gulp.src(['./bower_components/**/fonts/*']) |
|
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 | 95 |
}); |
96 |
||
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 | 100 |
}); |
101 |
||
102 |
gulp.task('copy-data', function() { |
|
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 | 105 |
}); |
106 |
||
107 |
gulp.task('copy-img', function() { |
|
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 | 110 |
}); |
111 |
||
112 |
gulp.task('watch',function(){ |
|
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 | 117 |
], function(event) { |
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 | 120 |
}); |
121 |
gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']); |
|
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 | 124 |
gulp.watch('./data/**/*',['copy-data']); |
125 |
gulp.watch('./img/**/*',['copy-img']); |
|
126 |
||
127 |
}); |
|
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 | 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']); |