forked from CoderDojo/cd-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (51 loc) · 1.38 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
var gulp = require('gulp');
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var semistandard = require('gulp-semistandard');
var concat = require('gulp-concat');
var less = require('gulp-less');
var del = require('del');
gulp.task('clean', function () {
return del('./dist/');
});
gulp.task('semistandard', function () {
return gulp.src([
'**/*.js',
'!node_modules/**/*',
'!dist/**/*'
])
.pipe(semistandard())
.pipe(semistandard.reporter('default', {
breakOnError: true
}));
});
gulp.task('build-less', ['clean'], function () {
return gulp.src('cd-common.less')
.pipe(less({
compress: true
}))
.pipe(autoprefixer())
.pipe(rename('cd-common.min.css'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('copy-images', ['clean'], function () {
return gulp.src('images/**/*')
.pipe(gulp.dest('./dist/'));
});
gulp.task('build-js', ['clean', 'semistandard'], function () {
return gulp.src([
'*/**/*.js',
'!node_modules/**/*',
'!dist/**/*'
])
.pipe(concat('cd-common.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist/'));
});
gulp.task('build', ['build-less', 'copy-images', 'build-js']);
gulp.task('watch', function () {
gulp.watch('**/*.less', ['build-less']);
gulp.watch('**/*.js', ['build-js']);
});
gulp.task('default', ['build']);