-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
200 lines (173 loc) · 5.85 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* File: gulpfile.js */
/* Gulp Packages */
var gulp = require('gulp'),
fs = require('fs'),
gutil = require('gulp-util'),
jade = require('gulp-jade'),
sass = require('gulp-sass'),
sassLint = require('gulp-sass-lint'),
jshint = require('gulp-jshint'),
minify = require('gulp-minifier'),
multiDest = require('gulp-multi-dest'),
rename = require('gulp-rename'),
header = require('gulp-header'),
clean = require('gulp-clean'),
browserSync = require('browser-sync').create();
var destOptions = {
mode: 0755
};
var pkg = JSON.parse(fs.readFileSync('package.json'));
// Task options
var opts = {
label: [
'/*!',
' * <%= name %> - <%= homepage %>',
' * Version: <%= version %>',
' * Demo: <%= demo %>',
' * Licensed under the MIT license - http://opensource.org/licenses/MIT',
' * Copyright (c) <%= new Date().getFullYear() %> <%= author %>',
' * ',
' * Facebook: @WarenGonzagaOfficialPage',
' * Twitter: @Waren_Gonzaga',
' * Github: @WarenGonzaga',
' * ',
' * Collaborator',
' * # SakhirAtwi - github.com/SakhirAtwi',
' */\n\n',
].join('\n'),
};
/**
* Gulp Tasks
* Writen by Waren Gonzaga
*/
gulp.task('default', ['init','jade','sass','jshint','build','update']);
gulp.task('init', function() {
gutil.log(gutil.colors.green('AnimateCSSPlugin for GreenSock'));
gutil.log(gutil.colors.green('Writen by Waren Gonzaga'));
});
gulp.task('dev', ['jade','sass','jshint','build','browserSync'], function() {
gulp.watch('source/*jade', ['jade'], gutil.log(
gutil.colors.cyan('Watching index.jade file...'),
gutil.colors.green('OK!')
));
gulp.watch('source/sass/**/*.scss', ['sass'], gutil.log(
gutil.colors.cyan('Watching sass files...'),
gutil.colors.green('OK!')
));
gulp.watch('source/javascript/**/*.js', ['jshint'], gutil.log(
gutil.colors.cyan('Watching javascript files...'),
gutil.colors.green('OK!')
));
gulp.watch('./demo/index.html', browserSync.reload)
gutil.log(gutil.colors.cyan('Watching Changes...'));
});
gulp.task('jade', function() {
gutil.log(gutil.colors.cyan('Compiling Jade file...'));
gutil.log(gutil.colors.cyan('Updating HTML...'));
gutil.log(gutil.colors.cyan('Status: '), gutil.colors.green('DONE!'));
gutil.log(gutil.colors.cyan('Watching Changes...'));
gulp.src('source/*.jade')
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('demo'));
});
gulp.task('sass', function() {
gutil.log(gutil.colors.cyan('Compiling SCSS Files...'));
gutil.log(gutil.colors.cyan('Updating CSS File'));
gutil.log(gutil.colors.cyan('Status: '), gutil.colors.green('DONE!'));
gutil.log(gutil.colors.cyan('Watching Changes...'));
gulp.src('source/sass/**/*.scss')
.pipe(sassLint())
.pipe(sassLint.failOnError())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename('demo/css/style.min.css'))
.pipe(browserSync.stream())
.pipe(gulp.dest(''));
});
gulp.task('jshint', function() {
gutil.log(gutil.colors.cyan('Updating JavaScript Files...'));
gutil.log(gutil.colors.cyan('Status: '), gutil.colors.green('DONE!'));
gutil.log(gutil.colors.cyan('Watching Changes...'));
/** Minified animateCSSplugin **/
gulp.src('source/javascript/animateCSSPlugin.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(minify({
minify: true,
collapseWhitespace: true,
conservativeCollapse: true,
minifyJS: true,
}))
.pipe(rename('demo/js/animateCSSPlugin.min.js'))
.pipe(browserSync.stream())
.pipe(gulp.dest(''));
/** Minified Script **/
gulp.src('source/javascript/script.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(minify({
minify: true,
collapseWhitespace: true,
conservativeCollapse: true,
minifyJS: true,
}))
.pipe(rename('demo/js/script.min.js'))
.pipe(browserSync.stream())
.pipe(gulp.dest(''));
});
gulp.task('build', function() {
gutil.log(gutil.colors.cyan('Building and Updating your animateCSSplugin'));
gutil.log(gutil.colors.cyan('By Waren Gonzaga...'));
/** Minified Build **/
gulp.src('./source/javascript/animateCSSPlugin.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(minify({
minify: true,
collapseWhitespace: true,
conservativeCollapse: true,
minifyJS: true,
}))
.pipe(rename('./build/animateCSSPlugin.min.js'))
.pipe(header(opts.label, pkg))
.pipe(gulp.dest(''));
gutil.log(gutil.colors.cyan('Minified:'), gutil.colors.green('DONE!!!'));
/** Production Build **/
gulp.src('./source/javascript/animateCSSPlugin.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(header(opts.label, pkg))
.pipe(multiDest(['./build','./demo/js'], destOptions));
gutil.log(gutil.colors.cyan('Production:'), gutil.colors.green('DONE!!!'));
gutil.log(gutil.colors.cyan('Status:'), gutil.colors.green('DONE!!!'));
gutil.log(gutil.colors.yellow('Do "gulp update" to update the downloadable version of AnimateCSSPlugin.'));
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: "./demo"
}
});
});
gulp.task('clean-build', function() {
return gulp.src('build', {read: false})
.pipe(clean());
});
gulp.task('clean-demo', function() {
return gulp.src('demo', {read: false})
.pipe(clean());
});
gulp.task('clean-animatecssplugin-dl', function() {
return gulp.src('./animateCSSPlugin.js', {read: false})
.pipe(clean());
});
gulp.task('clean-animatecssplugin.min-dl', function() {
return gulp.src('./animateCSSPlugin.min.js', {read: false})
.pipe(clean());
});
gulp.task('clean', ['clean-build','clean-demo','clean-animatecssplugin-dl','clean-animatecssplugin.min-dl']);
gulp.task('update', function() {
gulp.src('./build/*js')
.pipe(gulp.dest('./'));
});