-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
157 lines (127 loc) · 4.49 KB
/
Gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
////////////////////////////////////////////////////////////////////////////////////
// Imports
////////////////////////////////////////////////////////////////////////////////////
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var traceur = require('gulp-traceur');
var sass = require('gulp-ruby-sass');
var usemin = require('gulp-usemin');
var uglify = require('gulp-uglify');
var minifyHtml = require('gulp-minify-html');
var minifyCss = require('gulp-minify-css');
var rev = require('gulp-rev');
var notify = require('gulp-notify');
var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var debug = require('gulp-debug');
//var svgmin = require('gulp-svgmin');
////////////////////////////////////////////////////////////////////////////////////
// Tasks
////////////////////////////////////////////////////////////////////////////////////
gulp.task('build-sources', function () {
return gulp.src('src/javascript/**/*.js')
//.pipe(sourcemaps.init())
.pipe(traceur())
//.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build'));
});
gulp.task('copy-public', function () {
return gulp.src('public/**/*')
.pipe(gulp.dest('build/public'));
});
gulp.task('copy-public-html', function () {
return gulp.src('public/**/*.html')
.pipe(gulp.dest('build/public'));
});
gulp.task('copy-public-images', function () {
return gulp.src(['public/images/**/*.png', 'public/**/*.gif', 'public/**/*.jpg', 'public/**/*.jpeg'])
.pipe(gulp.dest('build/public/images'));
});
gulp.task('usemin-public-html', function () {
return gulp.src('public/index.html')
.pipe(usemin({
css: [minifyCss(), 'concat', rev(), rename({ extname: ".min.css" })],
app_css: [minifyCss(), 'concat', rev(), rename({ extname: ".min.css" })],
html: [minifyHtml({empty: true})],
js: [uglify(), 'concat', rev(), rename({ extname: ".min.js" })],
app_js: [ngAnnotate(), uglify(), rev(), rename({ extname: ".min.js" })]
}))
.pipe(gulp.dest('build/public'));
});
gulp.task('modernizr-min', function () {
return gulp.src('public/bower_components/modernizr/modernizr.js')
.pipe(uglify())
.pipe(rename({ extname: ".min.js" }))
.pipe(gulp.dest('public/bower_components/modernizr/'));
});
//
//gulp.task('ng-annotate-public-scripts', function () {
// return gulp.src('public/scripts/*.js')
// .pipe(ngAnnotate())
// .on('error', notify.onError("Error: <%= error.message %>"))
// .pipe(uglify())
// .on('error', notify.onError("Error: <%= error.message %>"))
// .pipe(rev())
// .on('error', notify.onError("Error: <%= error.message %>"))
// .pipe(rename({ extname: ".min.js" }))
// .pipe(gulp.dest('build/public/scripts'));
//});
gulp.task('copy-public-styles', function () {
return gulp.src('public/styles/**/*.css')
.pipe(gulp.dest('build/public/styles'));
});
gulp.task('copy-public-scripts', function () {
return gulp.src('public/scripts/**/*')
.pipe(gulp.dest('build/public/scripts'));
});
gulp.task('copy-views', function () {
return gulp.src('views/*')
.pipe(gulp.dest('build/views'));
});
gulp.task('copy-templates', function () {
return gulp.src('templates/**/*')
.pipe(gulp.dest('build/templates'));
});
gulp.task('copy-project-resources', function () {
return gulp.src('{package.json,README.md}')
.pipe(gulp.dest('build/'));
});
//gulp.task('copy-public-svg', function() {
// return gulp.src('public/images/**/*.svg')
// .pipe(svgmin())
// .pipe(gulp.dest('build/public/images'));
//});
gulp.task('build-sass', function () {
sass('src/sass', { style: 'expanded' })
.pipe(gulp.dest('public/styles'));
});
gulp.task('watch-sass', function() {
gulp.watch('src/sass/**/*.scss', ['build-sass']);
});
gulp.task('watch-views', function() {
gulp.watch('views/*', ['copy-views']);
});
gulp.task('watch-public-scripts', function() {
gulp.watch('public/scripts/**/*.js', ['copy-public-scripts']);
});
gulp.task('watch-public-html', function() {
gulp.watch('public/**/*.html', ['copy-public-html']);
});
gulp.task('watch-public-styles', function() {
gulp.watch('public/styles/**/*.css', ['copy-public-styles']);
});
gulp.task('watch-public-svg', function() {
gulp.watch('public/images/**/*.svg', ['copy-public-svg']);
});
gulp.task('watch', ['watch-sass', 'watch-views', 'watch-public-scripts']);
// default gulp task
gulp.task('default',
function(callback) {
runSequence(
['build-sources', 'build-sass', 'modernizr-min', 'copy-views', 'copy-templates', 'copy-project-resources'],
'copy-public',
'usemin-public-html',
callback
);
});