-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
173 lines (142 loc) · 4.8 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// Basic Gulp File
var debug = true;
var del = require('del'),
gulp = require('gulp');
var gulpsync = require('gulp-sync')(gulp),
bower = require('gulp-bower'),
notify = require("gulp-notify"),
uglify = require('gulp-uglify'),
rename = require("gulp-rename"),
sass = require('gulp-ruby-sass'),
autoprefix = require('gulp-autoprefixer');
var config = {
nodeDir: './node_modules',
bowerDir: './bower_components',
cssDir: './www/css',
sassDir: './www/scss',
fontsDir: './www/fonts',
jsDir: './www/js',
jsSrcDir: './www/js-src',
jsVendorDir: './www/js/vendor'
};
/************************************ Bower ***********************************/
// Bower
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.bowerDir))
});
/************************************ Icons ***********************************/
// Font awesome
gulp.task('fontawesome-icons', function() {
return gulp.src(config.bowerDir + '/fontawesome/fonts/**.*')
.pipe(gulp.dest(config.fontsDir + '/fontawesome'));
});
// Bootstrap icons
gulp.task('bootstrap-icons', function() {
return gulp.src(config.bowerDir + '/bootstrap-sass-official/assets/fonts/bootstrap/**.*')
.pipe(gulp.dest(config.fontsDir + '/bootstrap'));
});
gulp.task('icons', ['fontawesome-icons', 'bootstrap-icons']);
/********************************* Stylesheets ********************************/
// Stylesheets
gulp.task('scss', function() {
return gulp.src(config.sassDir + '/main.scss')
.pipe(sass({
style: 'compressed'
})
.on("error", notify.onError(function (error) {
return "Error: " + error.message;
}))
)
.pipe(autoprefix('last 4 versions'))
.pipe(gulp.dest(config.cssDir));
});
/********************************* JavaScript *********************************/
// Angular JS
gulp.task('angular-js', function() {
return gulp.src(config.bowerDir + '/angular/angular.min.js')
.pipe(gulp.dest(config.jsVendorDir));
});
// Angular-Route JS
gulp.task('angular-route-js', function() {
return gulp.src(config.bowerDir + '/angular-route/angular-route.min.js')
.pipe(gulp.dest(config.jsVendorDir));
});
// Angular-Cookies JS
gulp.task('angular-cookies-js', function() {
return gulp.src(config.bowerDir + '/angular-cookies/angular-cookies.min.js')
.pipe(gulp.dest(config.jsVendorDir));
});
// Angular-Sanitize JS
gulp.task('angular-sanitize-js', function() {
return gulp.src(config.bowerDir + '/angular-sanitize/angular-sanitize.min.js')
.pipe(gulp.dest(config.jsVendorDir));
});
// Angular-Localization JS
gulp.task('angular-localization-js', function() {
return gulp.src(config.bowerDir + '/angular-localization/angular-localization.min.js')
.pipe(gulp.dest(config.jsVendorDir));
});
// Bootstrap JS
gulp.task('bootstrap-js', function() {
return gulp.src(config.bowerDir + '/bootstrap-sass-official/assets/javascripts/bootstrap.min.js')
.pipe(gulp.dest(config.jsVendorDir));
});
// Fastclick JS
gulp.task('fastclick-js', function() {
return gulp.src(config.bowerDir + '/fastclick/lib/fastclick.js')
.pipe(uglify())
.pipe(rename('fastclick.min.js'))
.pipe(gulp.dest(config.jsVendorDir));
});
// Jquery JS
gulp.task('jquery-js', function() {
return gulp.src(config.bowerDir + '/jquery/dist/jquery.min.js')
.pipe(gulp.dest(config.jsVendorDir));
});
// Cordova JS
gulp.task('cordova-js', function() {
return gulp.src(config.bowerDir + '/cordova/**/*.js')
.pipe(gulp.dest(config.jsVendorDir + '/cordova'));
});
// Vendor JS
gulp.task('js-vendor', [
'angular-js',
'angular-route-js',
'angular-cookies-js',
'angular-sanitize-js',
'angular-localization-js',
'bootstrap-js',
'fastclick-js',
'jquery-js',
'cordova-js'
]);
// Src JS
gulp.task('js-src', function() {
var cmd = gulp.src(config.jsSrcDir + '/**/*.js');
return debug || (cmd = cmd.pipe(uglify())),
cmd.pipe(gulp.dest(config.jsDir));
});
gulp.task('js', ['js-src', 'js-vendor']);
/************************************ Main ************************************/
// Rerun the task when a file changes
gulp.task('watch', ['default'], function() {
gulp.watch(config.sassDir + '/**/*.scss', ['scss']);
gulp.watch(config.jsSrcDir + '/**/*.js', ['js-src']);
});
// Clean folders
gulp.task('clean', function(cb) {
return del([
'.sass-cache',
config.cssDir + '/*',
config.fontsDir + '/bootstrap/*',
config.fontsDir + '/fontawesome/*',
config.jsDir + '/*'
], cb);
});
// Build
gulp.task('build', ['bower', 'icons', 'scss', 'js']);
// Clen build
gulp.task('clean-build', gulpsync.sync(['clean', 'build']));
// Default -> Clean build
gulp.task('default', ['clean-build']);