author | rougeronj |
Sat, 18 Apr 2015 09:37:57 +0200 | |
changeset 167 | 2b99fed0285e |
parent 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}); |
|
158
c7e0e3212b4c
Update gulfile : uses main-bower-files to concatenate main js of each library.
rougeronj
parents:
81
diff
changeset
|
5 |
var mainBowerFiles = require('main-bower-files'); |
1 | 6 |
|
81 | 7 |
var templateFolder = '../../annot-server/webapp/templates/'; |
8 |
var staticFolder = '../../annot-server/static'; |
|
4
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 |
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
|
16 |
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
|
17 |
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
|
18 |
],{'force':true}, cb); |
1 | 19 |
}); |
20 |
||
21 |
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js']; |
|
22 |
||
23 |
gulp.task('scripts', function(){ |
|
24 |
//combine all js files of the app |
|
25 |
gulp.src(scriptsSrc) |
|
26 |
.pipe(plugins.jshint()) |
|
27 |
.pipe(plugins.jshint.reporter('default')) |
|
28 |
.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
|
29 |
.pipe(plugins.concat(clientBaseName+'.js')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
30 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 31 |
.pipe(plugins.filesize()) |
32 |
.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
|
33 |
.pipe(plugins.rename(clientBaseName+'.min.js')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
34 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 35 |
.pipe(plugins.filesize()) |
36 |
.on('error', gutil.log); |
|
37 |
}); |
|
38 |
||
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
39 |
|
1 | 40 |
gulp.task('css', function(){ |
41 |
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
|
42 |
.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
|
43 |
.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
|
44 |
.pipe(plugins.concat(clientBaseName+'.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
45 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 46 |
.pipe(plugins.filesize()) |
47 |
.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
|
48 |
.pipe(plugins.rename(clientBaseName+'.min.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
49 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 50 |
.pipe(plugins.filesize()); |
51 |
}); |
|
52 |
||
53 |
gulp.task('vendorJS', function(){ |
|
54 |
//concatenate vendor JS files |
|
158
c7e0e3212b4c
Update gulfile : uses main-bower-files to concatenate main js of each library.
rougeronj
parents:
81
diff
changeset
|
55 |
return gulp.src(mainBowerFiles()) |
1 | 56 |
.pipe(plugins.concat('lib.js')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
57 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 58 |
.pipe(plugins.filesize()) |
59 |
.pipe(plugins.uglify()) |
|
60 |
.pipe(plugins.rename('lib.min.js')) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
61 |
.pipe(gulp.dest(staticFolder+'/js')) |
1 | 62 |
.pipe(plugins.filesize()) |
63 |
.on('error', gutil.log); |
|
64 |
}); |
|
65 |
||
66 |
gulp.task('vendorCSS', function(){ |
|
67 |
//concatenate vendor CSS files |
|
68 |
gulp.src(['!./bower_components/**/*.min.css', |
|
69 |
'./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
|
70 |
.pipe(plugins.concat(vendorBaseName+'.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
71 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 72 |
.pipe(plugins.filesize()) |
73 |
.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
|
74 |
.pipe(plugins.rename(vendorBaseName+'.min.css')) |
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
75 |
.pipe(gulp.dest(staticFolder+'/css')) |
1 | 76 |
.pipe(plugins.filesize()); |
77 |
}); |
|
78 |
||
79 |
gulp.task('vendorFonts', function(){ |
|
80 |
gulp.src(['./bower_components/**/fonts/*']) |
|
81 |
.pipe(plugins.flatten()) |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
82 |
.pipe(gulp.dest(staticFolder+'/css/fonts')); |
1 | 83 |
}); |
84 |
||
85 |
gulp.task('copy-index', function() { |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
86 |
gulp.src('./app/annotationclient.html') |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
87 |
.pipe(gulp.dest(templateFolder)); |
1 | 88 |
}); |
89 |
||
90 |
gulp.task('copy-data', function() { |
|
91 |
gulp.src('./data/**/*') |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
92 |
.pipe(gulp.dest(staticFolder+'/data')); |
1 | 93 |
}); |
94 |
||
95 |
gulp.task('copy-img', function() { |
|
96 |
gulp.src('./img/**/*') |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
97 |
.pipe(gulp.dest(staticFolder+'/img')); |
1 | 98 |
}); |
99 |
||
100 |
gulp.task('watch',function(){ |
|
101 |
gulp.watch([ |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
102 |
templateFolder+'/**/*.html', |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
103 |
staticFolder+'/**/*.js', |
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
104 |
staticFolder+'/**/*.css' |
1 | 105 |
], function(event) { |
106 |
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
|
107 |
.pipe(plugins.webserver.reload()); |
1 | 108 |
}); |
109 |
gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']); |
|
110 |
gulp.watch('./app/**/*.css',['css']); |
|
4
9c70d81e9062
update gulpfile for template to work with twistd/flask
cavaliet
parents:
1
diff
changeset
|
111 |
gulp.watch('./app/annotationclient.html',['copy-index']); |
1 | 112 |
gulp.watch('./data/**/*',['copy-data']); |
113 |
gulp.watch('./img/**/*',['copy-img']); |
|
114 |
||
115 |
}); |
|
116 |
||
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
|
117 |
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
|
118 |
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
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
}) |
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
|
123 |
); |
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
|
124 |
}); |
1 | 125 |
|
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
|
126 |
gulp.task('default',['scripts','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts']); |