| author | rougeronj |
| Wed, 08 Apr 2015 17:02:32 +0200 | |
| changeset 83 | 6a169ef52314 |
| parent 78 | aaffa46a2b79 |
| child 88 | 2db951a4a04c |
| permissions | -rw-r--r-- |
| 0 | 1 |
var gulp = require('gulp'); |
2 |
var gutil = require('gulp-util') |
|
3 |
var plugins = require("gulp-load-plugins")({lazy:false}); |
|
|
78
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
4 |
var htmlreplace = require('gulp-html-replace'); |
| 0 | 5 |
//var flatten = require('gulp-flatten'); |
6 |
//var uglify = require('gulp-uglify'); |
|
7 |
//var clean = require('gulp-clean'); |
|
8 |
//var rename = require('gulp-rename'); |
|
9 |
//var filesize = require('gulp-filesize'); |
|
10 |
//var cssmin = require('gulp-cssmin'); |
|
11 |
||
12 |
gulp.task('clean', function () { |
|
13 |
return gulp.src('build', {read: false}) |
|
14 |
.pipe(clean()); |
|
15 |
}); |
|
16 |
||
17 |
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js']; |
|
18 |
||
19 |
gulp.task('scripts', function(){ |
|
20 |
//combine all js files of the app |
|
21 |
gulp.src(scriptsSrc) |
|
22 |
.pipe(plugins.jshint()) |
|
23 |
.pipe(plugins.jshint.reporter('default')) |
|
24 |
.pipe(plugins.jshint.reporter('fail')) |
|
25 |
.pipe(plugins.concat('app.js')) |
|
26 |
.pipe(gulp.dest('./build')) |
|
27 |
.pipe(plugins.filesize()) |
|
28 |
.pipe(plugins.uglify()) |
|
29 |
.pipe(plugins.rename('app.min.js')) |
|
30 |
.pipe(gulp.dest('./build')) |
|
31 |
.pipe(plugins.filesize()) |
|
32 |
.on('error', gutil.log); |
|
33 |
}); |
|
34 |
||
35 |
gulp.task('templates',function(){ |
|
36 |
//combine all template files of the app into a js file |
|
37 |
gulp.src(['!./app/index.html', |
|
38 |
'./app/**/*.html']) |
|
39 |
.pipe(plugins.angularTemplatecache('templates.js',{standalone:true})) |
|
40 |
.pipe(gulp.dest('./build')); |
|
41 |
}); |
|
42 |
||
43 |
gulp.task('css', function(){ |
|
44 |
gulp.src('./app/**/*.css') |
|
45 |
// .pipe(plugins.csslint()) |
|
46 |
// .pipe(plugins.csslint.reporter()) |
|
47 |
.pipe(plugins.concat('app.css')) |
|
48 |
.pipe(gulp.dest('./build')) |
|
49 |
.pipe(plugins.filesize()) |
|
50 |
.pipe(plugins.minifyCss({keepBreaks:true})) |
|
51 |
.pipe(plugins.rename('app.min.css')) |
|
52 |
.pipe(gulp.dest('./build')) |
|
53 |
.pipe(plugins.filesize()); |
|
54 |
}); |
|
55 |
||
56 |
var vendorJSsrc = [ |
|
57 |
'!./bower_components/**/*.min.js', |
|
|
44
5eab9718182b
FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents:
0
diff
changeset
|
58 |
'!./bower_components/bootstrap/**/*', |
| 0 | 59 |
'!./bower_components/jquery/src/**/*', |
|
49
88cd0bb61c12
add ui-sortble lib to be able to sort the list of the slide in the book view - it sends a post request to the server to update the slides' order
rougeronj
parents:
44
diff
changeset
|
60 |
'!./bower_components/jquery-ui/themes/**', |
|
88cd0bb61c12
add ui-sortble lib to be able to sort the list of the slide in the book view - it sends a post request to the server to update the slides' order
rougeronj
parents:
44
diff
changeset
|
61 |
'!./bower_components/jquery-ui/ui/**', |
|
88cd0bb61c12
add ui-sortble lib to be able to sort the list of the slide in the book view - it sends a post request to the server to update the slides' order
rougeronj
parents:
44
diff
changeset
|
62 |
'!./bower_components/jquery-ui/ui/*.js', |
|
44
5eab9718182b
FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents:
0
diff
changeset
|
63 |
'!./bower_components/**/index.js', |
|
5eab9718182b
FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents:
0
diff
changeset
|
64 |
'./bower_components/bootstrap/dist/css/*', |
| 0 | 65 |
'./bower_components/jquery/dist/jquery.js', |
|
44
5eab9718182b
FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents:
0
diff
changeset
|
66 |
'./bower_components/angular/angular.js', |
|
5eab9718182b
FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents:
0
diff
changeset
|
67 |
'./bower_components/angular-route/angular-route.js', |
|
5eab9718182b
FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents:
0
diff
changeset
|
68 |
'./bower_components/angular-resource/angular-resource.js', |
|
5eab9718182b
FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents:
0
diff
changeset
|
69 |
'./bower_components/angular-bootstrap/ui-bootstrap.js', |
| 0 | 70 |
'./bower_components/**/*.js' |
71 |
]; |
|
72 |
||
73 |
gulp.task('vendorJS', function(){ |
|
74 |
//concatenate vendor JS files |
|
75 |
gulp.src(vendorJSsrc) |
|
76 |
.pipe(plugins.concat('lib.js')) |
|
77 |
.pipe(gulp.dest('./build')) |
|
78 |
.pipe(plugins.filesize()) |
|
79 |
.pipe(plugins.uglify()) |
|
80 |
.pipe(plugins.rename('lib.min.js')) |
|
81 |
.pipe(gulp.dest('./build')) |
|
82 |
.pipe(plugins.filesize()) |
|
83 |
.on('error', gutil.log); |
|
84 |
}); |
|
85 |
||
86 |
gulp.task('vendorCSS', function(){ |
|
87 |
//concatenate vendor CSS files |
|
88 |
gulp.src(['!./bower_components/**/*.min.css', |
|
89 |
'./bower_components/**/*.css']) |
|
90 |
.pipe(plugins.concat('lib.css')) |
|
91 |
.pipe(gulp.dest('./build')) |
|
92 |
.pipe(plugins.filesize()) |
|
93 |
.pipe(plugins.minifyCss({keepBreaks:true})) |
|
94 |
.pipe(plugins.rename('lib.min.css')) |
|
95 |
.pipe(gulp.dest('./build')) |
|
96 |
.pipe(plugins.filesize()); |
|
97 |
}); |
|
98 |
||
99 |
gulp.task('vendorFonts', function(){ |
|
100 |
gulp.src(['./bower_components/**/fonts/*']) |
|
101 |
.pipe(plugins.flatten()) |
|
102 |
.pipe(gulp.dest('./build/fonts')); |
|
103 |
}); |
|
104 |
||
105 |
gulp.task('copy-index', function() { |
|
106 |
gulp.src('./app/index.html') |
|
107 |
.pipe(gulp.dest('./build')); |
|
108 |
}); |
|
109 |
||
110 |
gulp.task('copy-data', function() { |
|
111 |
gulp.src('./data/**/*') |
|
112 |
.pipe(gulp.dest('./build/data')); |
|
113 |
}); |
|
114 |
||
115 |
gulp.task('copy-img', function() { |
|
116 |
gulp.src('./img/**/*') |
|
117 |
.pipe(gulp.dest('./build/img')); |
|
118 |
}); |
|
119 |
||
|
78
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
120 |
gulp.task('copy-server', function() { |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
121 |
gulp.src('./build/img/**/*') |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
122 |
.pipe(gulp.dest('./../server/ammico/static/ammico/img')); |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
123 |
gulp.src('./build/fonts/**/*') |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
124 |
.pipe(gulp.dest('./../server/ammico/static/ammico/fonts')); |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
125 |
gulp.src('./build/*.js') |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
126 |
.pipe(gulp.dest('./../server/ammico/static/ammico/js')); |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
127 |
gulp.src('./build/*.css') |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
128 |
.pipe(gulp.dest('./../server/ammico/static/ammico/css')); |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
129 |
gulp.src('./app/index.html') |
| 83 | 130 |
.pipe(htmlreplace({ |
131 |
django: '{% load static %}', |
|
132 |
js:{ |
|
133 |
src: ['lib.js', 'templates.js', 'app.js'], |
|
134 |
tpl: '<script src="{% static \'ammico/js/%s\' %}"></script>' |
|
135 |
}, |
|
136 |
css: { |
|
137 |
src: ['lib.css', 'app.css'], |
|
138 |
tpl: '<link rel="stylesheet" type="text/css" href="{% static \'ammico/css/%s\' %}"/>' |
|
139 |
}, |
|
140 |
imgLogo: { |
|
141 |
src: 'ammico_logo_small.png', |
|
142 |
tpl: '<img src="{% static \'ammico/img/%s\' %}">' |
|
143 |
}, |
|
144 |
imgFooter: { |
|
145 |
src: 'logo_IRI_footer.png', |
|
146 |
tpl: '<img src="{% static \'ammico/img/%s\' %}" alt="Logo IRI" />' |
|
147 |
} |
|
148 |
})) |
|
|
78
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
149 |
.pipe(gulp.dest('./../server/ammico/templates')); |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
150 |
}); |
|
aaffa46a2b79
add gulp task "copy-server" to copy the project built, on the django server
rougeronj
parents:
49
diff
changeset
|
151 |
|
| 0 | 152 |
gulp.task('watch',function(){ |
153 |
gulp.watch([ |
|
154 |
'build/**/*.html', |
|
155 |
'build/**/*.js', |
|
156 |
'build/**/*.css' |
|
157 |
], function(event) { |
|
158 |
return gulp.src(event.path) |
|
159 |
.pipe(plugins.connect.reload()); |
|
160 |
}); |
|
161 |
gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']); |
|
162 |
gulp.watch(['!./app/index.html','./app/**/*.html'],['templates']); |
|
163 |
gulp.watch('./app/**/*.css',['css']); |
|
164 |
gulp.watch('./app/index.html',['copy-index']); |
|
165 |
gulp.watch('./data/**/*',['copy-data']); |
|
166 |
gulp.watch('./img/**/*',['copy-img']); |
|
167 |
||
168 |
}); |
|
169 |
||
170 |
gulp.task('connect', plugins.connect.server({ |
|
171 |
root: ['build'], |
|
172 |
port: 9000, |
|
173 |
livereload: true |
|
174 |
})); |
|
175 |
||
176 |
gulp.task('default',['connect','scripts','templates','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']); |