| author | rougeronj |
| Fri, 27 Mar 2015 16:33:30 +0100 | |
| changeset 44 | 5eab9718182b |
| parent 0 | cef349423167 |
| child 49 | 88cd0bb61c12 |
| 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}); |
|
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 |
||
11 |
gulp.task('clean', function () { |
|
12 |
return gulp.src('build', {read: false}) |
|
13 |
.pipe(clean()); |
|
14 |
}); |
|
15 |
||
16 |
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js']; |
|
17 |
||
18 |
gulp.task('scripts', function(){ |
|
19 |
//combine all js files of the app |
|
20 |
gulp.src(scriptsSrc) |
|
21 |
.pipe(plugins.jshint()) |
|
22 |
.pipe(plugins.jshint.reporter('default')) |
|
23 |
.pipe(plugins.jshint.reporter('fail')) |
|
24 |
.pipe(plugins.concat('app.js')) |
|
25 |
.pipe(gulp.dest('./build')) |
|
26 |
.pipe(plugins.filesize()) |
|
27 |
.pipe(plugins.uglify()) |
|
28 |
.pipe(plugins.rename('app.min.js')) |
|
29 |
.pipe(gulp.dest('./build')) |
|
30 |
.pipe(plugins.filesize()) |
|
31 |
.on('error', gutil.log); |
|
32 |
}); |
|
33 |
||
34 |
gulp.task('templates',function(){ |
|
35 |
//combine all template files of the app into a js file |
|
36 |
gulp.src(['!./app/index.html', |
|
37 |
'./app/**/*.html']) |
|
38 |
.pipe(plugins.angularTemplatecache('templates.js',{standalone:true})) |
|
39 |
.pipe(gulp.dest('./build')); |
|
40 |
}); |
|
41 |
||
42 |
gulp.task('css', function(){ |
|
43 |
gulp.src('./app/**/*.css') |
|
44 |
// .pipe(plugins.csslint()) |
|
45 |
// .pipe(plugins.csslint.reporter()) |
|
46 |
.pipe(plugins.concat('app.css')) |
|
47 |
.pipe(gulp.dest('./build')) |
|
48 |
.pipe(plugins.filesize()) |
|
49 |
.pipe(plugins.minifyCss({keepBreaks:true})) |
|
50 |
.pipe(plugins.rename('app.min.css')) |
|
51 |
.pipe(gulp.dest('./build')) |
|
52 |
.pipe(plugins.filesize()); |
|
53 |
}); |
|
54 |
||
55 |
var vendorJSsrc = [ |
|
56 |
'!./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
|
57 |
'!./bower_components/bootstrap/**/*', |
| 0 | 58 |
'!./bower_components/jquery/src/**/*', |
|
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
|
59 |
'!./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
|
60 |
'./bower_components/bootstrap/dist/css/*', |
| 0 | 61 |
'./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
|
62 |
'./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
|
63 |
'./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
|
64 |
'./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
|
65 |
'./bower_components/angular-bootstrap/ui-bootstrap.js', |
| 0 | 66 |
'./bower_components/**/*.js' |
67 |
]; |
|
68 |
||
69 |
gulp.task('vendorJS', function(){ |
|
70 |
//concatenate vendor JS files |
|
71 |
gulp.src(vendorJSsrc) |
|
72 |
.pipe(plugins.concat('lib.js')) |
|
73 |
.pipe(gulp.dest('./build')) |
|
74 |
.pipe(plugins.filesize()) |
|
75 |
.pipe(plugins.uglify()) |
|
76 |
.pipe(plugins.rename('lib.min.js')) |
|
77 |
.pipe(gulp.dest('./build')) |
|
78 |
.pipe(plugins.filesize()) |
|
79 |
.on('error', gutil.log); |
|
80 |
}); |
|
81 |
||
82 |
gulp.task('vendorCSS', function(){ |
|
83 |
//concatenate vendor CSS files |
|
84 |
gulp.src(['!./bower_components/**/*.min.css', |
|
85 |
'./bower_components/**/*.css']) |
|
86 |
.pipe(plugins.concat('lib.css')) |
|
87 |
.pipe(gulp.dest('./build')) |
|
88 |
.pipe(plugins.filesize()) |
|
89 |
.pipe(plugins.minifyCss({keepBreaks:true})) |
|
90 |
.pipe(plugins.rename('lib.min.css')) |
|
91 |
.pipe(gulp.dest('./build')) |
|
92 |
.pipe(plugins.filesize()); |
|
93 |
}); |
|
94 |
||
95 |
gulp.task('vendorFonts', function(){ |
|
96 |
gulp.src(['./bower_components/**/fonts/*']) |
|
97 |
.pipe(plugins.flatten()) |
|
98 |
.pipe(gulp.dest('./build/fonts')); |
|
99 |
}); |
|
100 |
||
101 |
gulp.task('copy-index', function() { |
|
102 |
gulp.src('./app/index.html') |
|
103 |
.pipe(gulp.dest('./build')); |
|
104 |
}); |
|
105 |
||
106 |
gulp.task('copy-data', function() { |
|
107 |
gulp.src('./data/**/*') |
|
108 |
.pipe(gulp.dest('./build/data')); |
|
109 |
}); |
|
110 |
||
111 |
gulp.task('copy-img', function() { |
|
112 |
gulp.src('./img/**/*') |
|
113 |
.pipe(gulp.dest('./build/img')); |
|
114 |
}); |
|
115 |
||
116 |
gulp.task('watch',function(){ |
|
117 |
gulp.watch([ |
|
118 |
'build/**/*.html', |
|
119 |
'build/**/*.js', |
|
120 |
'build/**/*.css' |
|
121 |
], function(event) { |
|
122 |
return gulp.src(event.path) |
|
123 |
.pipe(plugins.connect.reload()); |
|
124 |
}); |
|
125 |
gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']); |
|
126 |
gulp.watch(['!./app/index.html','./app/**/*.html'],['templates']); |
|
127 |
gulp.watch('./app/**/*.css',['css']); |
|
128 |
gulp.watch('./app/index.html',['copy-index']); |
|
129 |
gulp.watch('./data/**/*',['copy-data']); |
|
130 |
gulp.watch('./img/**/*',['copy-img']); |
|
131 |
||
132 |
}); |
|
133 |
||
134 |
gulp.task('connect', plugins.connect.server({ |
|
135 |
root: ['build'], |
|
136 |
port: 9000, |
|
137 |
livereload: true |
|
138 |
})); |
|
139 |
||
140 |
gulp.task('default',['connect','scripts','templates','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']); |