-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (59 loc) · 1.53 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
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var stylus = require('gulp-stylus');
var imagemin = require('gulp-imagemin');
var rm = require('del');
var browserSync = require('browser-sync');
var path = require('path');
var paths = {
js: ['app/*/*.js', '!app/lib/**'],
css: 'app/*/*.styl',
img: 'app/img/*',
index: '*.html',
dist: 'dist'
};
gulp.task('lint', function () {
return gulp.src(paths.js)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter())
.pipe(jshint.reporter('fail'));
});
gulp.task('js', function () {
return gulp.src(paths.js)
.pipe(concat('bundle.js'))
.pipe(uglify())
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('build', ['lint', 'js', 'css', 'img']);
gulp.task('css', function () {
return gulp.src(paths.css)
.pipe(stylus())
.pipe(gulp.dest('dist/css'));
});
gulp.task('img', function () {
return gulp.src(paths.img)
.pipe(imagemin())
.pipe(gulp.dest('dist/img'));
});
gulp.task('serve', function () {
browserSync({
server: {
baseDir: path.join(__dirname, 'app')
}
});
gulp.watch([paths.js, paths.css, paths.img], ['js', 'css', 'img', browserSync.reload])
gulp.watch([paths.index, 'dist/*'], browserSync.reload);
});
gulp.task('clean', function (callback) {
rm(['dist'], callback);
});
gulp.task('watch', function () {
gulp.watch([paths.js, paths.index, paths.css], ['build', 'css'])
});
gulp.task('default', ['serve']);