-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
executable file
·241 lines (184 loc) · 5.98 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var jade = require('gulp-jade');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var Filter = require('gulp-filter');
var lr = require('gulp-livereload');
var gif = require('gulp-if');
var cached = require('gulp-cached');
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var nib = require('nib');
var autoprefixer = require('autoprefixer-stylus');
var plumber = require('gulp-plumber');
var minifyCss = require('gulp-minify-css');
var git = require('gulp-git');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer-core');
var mqpacker = require('css-mqpacker');
var csswring = require('csswring');
var sourcemaps = require('gulp-sourcemaps');
var bump = require('gulp-bump');
//var autoprefixer = require('gulp-autoprefixer');
//Broswer reloading
var browserSync = require('browser-sync').create();
// define the default task and add the watch task to it
gulp.task('default', ['watch','serve', 'build']);
gulp.task('stylus', function () {
var processors = [
autoprefixer({browsers: ['last 2 version']})
];
gulp.src(
[
'./src/stylus/inventive.styl',
'./src/stylus/extra/doc.styl',
], { base: 'src/stylus' }
)
//.pipe(cached('build'))
.pipe(plumber(swallowError))
.pipe(stylus())
.pipe(postcss(processors))
.pipe(gulp.dest('./build/css'))
.pipe(browserSync.stream())
;
gulp.src([
'./src/stylus/*.styl',
'./src/stylus/**/*.styl',
'!./src/stylus/**/_*.styl'
], { base: 'src/stylus' })
.pipe(plumber(swallowError))
.pipe(stylus()) //{error: true, use: [nib()]}}
.pipe(postcss(processors) )
.pipe(gulp.dest('./build/css'))
;
//TODO start using sourcemaps
//.pipe(sourcemaps.init())
//.pipe(autoprefixer())
//.pipe(sourcemaps.write('.'))
//.pipe(gulp.dest('./build/css/'));
});
gulp.task('jade', function () {
return gulp.src(
[
'./src/jade/*.jade',
'!./src/jade/_*.jade'
], { base: 'src/jade' }
)
.pipe(cached('build'))
.pipe(plumber(swallowError))
.pipe(jade({pretty:true}))
.pipe(gulp.dest('./build/docs'))
.pipe(browserSync.stream())
;
});
gulp.task('coffee', function () {
return gulp.src([
'./src/coffeescript/*.coffee',
'!./src/coffeescript/_*.coffee',
'!./src/coffeescript/doc.coffee'
], { base: 'src/coffeescript' }
)
.pipe(plumber(swallowError))
.pipe(coffee({bare: true}))
.pipe(gulp.dest('./build/js/components'))
.pipe(concat('inventive.js'))
.pipe(gulp.dest('./build/js'))
.pipe(browserSync.stream())
;
});
gulp.task('vendors', function () {
gulp.src([
"bower_components/jquery/dist/jquery.js",
"build/js/components/doc.js",
"bower_components/prism/prism.js"
])
.pipe(plumber(swallowError))
.pipe(concat('vendors.js'))
.pipe(uglify())
.pipe(gulp.dest('./build/js/'))
;
gulp.src([
"bower_components/prism/themes/prism.css",
'build/css/extra/doc.css',
'bower_components/inventive-font/fonts/stripe-font.css'
])
.pipe(plumber(swallowError))
.pipe(concat('vendors.css'))
.pipe(minifyCss())
.pipe(gulp.dest('./build/css/'))
;
gulp.src('bower_components/inventive-font/fonts/*.{ttf,woff,eof,svg}')
.pipe(gulp.dest('./build/fonts'));
gulp.src('src/img/**/*')
.pipe(gulp.dest('./build/img'));
});
// configure which files to watch and what tasks to use on file changes
gulp.task('watch', function() {
gulp.watch('src/stylus/**/*.styl', ['stylus']);
gulp.watch('src/jade/*.jade', ['jade']);
gulp.watch('src/coffeescript/*.coffee', ['coffee']);
});
// doc Server + watching stylus/html files
gulp.task('serve', ['stylus','jade','coffee'], function() {
browserSync.init({
server: "./build/"
});
gulp.watch("build/css/**/*.css").on('change', browserSync.reload);
gulp.watch("build/docs/*.html").on('change', browserSync.reload);
gulp.watch("build/js/*.js").on('change', browserSync.reload);
});
//Related to release and publish build
gulp.task('build', ['stylus','jade','coffee', 'vendors']);
gulp.task('bump', ['build'], function(){
console.log('In Bump')
gulp.src(['./bower.json', './package.json'])
.pipe(bump({version:'0.9.7'}))
.pipe(gulp.dest('./'));
});
gulp.task('tag', ['bump'], function () {
var pkg = require('./package.json');
var v = pkg.version;
var message = 'Release ' + v;
gulp.src('./')
.pipe(git.commit(message))
.pipe(gulp.dest('./'));
git.tag(v, message, function (err) {
if (err) throw err;
});
git.push('origin', 'master',{args: '--tags'} , function (err) {
if (err) throw err;
});
});
gulp.task('npm', ['tag'],function (done) {
require('child_process').spawn('npm', ['publish'], { stdio: 'inherit' })
.on('close', done);
});
gulp.task('release', ['npm']);
gulp.task('ci', ['build']);
function swallowError (error) {
//If you want details of the error in the console
console.log(error.toString());
this.emit('end');
}
//SAMPLE for learning Gulp ;)
// gulp.task('default', function(){
// return gulp.src('src/**/*')
// .pipe(cached('build'))
// .pipe(gif('*.styl', stylus({
// use:[
// nib(),
// autoprefixer()
// ]
// })))
// .pipe(gif('*.js', uglify()))
// .pipe(gulp.dest('dist'))
// .pipe(lr());
// });
// gulp.watch('src/**/*', ['default']);
// configure the jshint task
// gulp.task('jshint', function() {
// return gulp.src('source/javascript/**/*.js')
// .pipe(jshint())
// .pipe(jshint.reporter('jshint-stylish'));
// });