This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 740
/
gulpfile.js
90 lines (77 loc) · 2.07 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
'use strict';
const gulp = require('gulp');
const jshint = require('gulp-jshint');
const stylish = require('jshint-stylish');
const rename = require('gulp-rename');
const jscs = require('gulp-jscs');
const uglify = require('gulp-uglify');
const livereload = require('gulp-livereload');
const exec = require('child_process').exec;
gulp.task('default', ['watch']);
gulp.task('watch', () => {
livereload.listen(35730);
gulp.watch([
'./src/*.js',
'./src/*.hbs'
], ['reload-js'])
.on('change', function(e) {
console.log(
'[gulp-watch] file ' +
e.path +
' was ' +
e.type +
', building'
);
});
});
gulp.task('reload-js', ['build-dist'], () => {
return livereload.changed();
});
gulp.task('prod', ['uglify']);
gulp.task('uglify', ['build'], () => {
return gulp.src([
'./dist/mixitup.js'
])
.pipe(uglify({
preserveComments: 'license'
}))
.pipe(rename('mixitup.min.js'))
.on('error', e => console.error('[uglify] ' + e.message))
.pipe(gulp.dest('./dist/'))
.pipe(gulp.dest('./demos/'));
});
gulp.task('build', ['build-dist'], done => {
exec('node node_modules/mixitup-build/docs.js -s mixitup.js', (e, out) => {
if (out) {
console.log(out);
}
done(e);
});
});
gulp.task('build-dist', ['lint', 'code-style'], done => {
exec('node node_modules/mixitup-build/dist.js -o mixitup.js', (e, out) => {
if (out) {
console.log(out);
}
done(e);
});
});
gulp.task('lint', () => {
return gulp.src([
'./src/*.js'
], {
base: '/'
})
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('code-style', () => {
return gulp.src([
'./src/*.js'
], {
base: '/'
})
.pipe(jscs())
.pipe(jscs.reporter());
});