-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
126 lines (88 loc) · 2.5 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
var gulp = require('gulp');
var jade = require('gulp-jade');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var rename = require('gulp-rename');
var imagemin = require('gulp-imagemin');
var uglify = require('gulp-uglify');
var del = require('del');
var connect = require('gulp-connect');
var plumber = require('gulp-plumber');
var livereload = require('gulp-livereload');
// *************************************
// GULP BUILD
// *************************************
gulp.task('build', ['clean'], function() {
gulp.start('jade', 'sass', 'image', 'script');
});
// ***********************************
// GULP JADE
// ***********************************
gulp.task('jade', function() {
return gulp.src(['src/*.jade', '!src/_*.jade'])
.pipe(plumber())
.pipe(jade({pretty: true}))
.pipe(gulp.dest('dist'))
.pipe(connect.reload());
});
// ***********************************
// GULP SASS
// ***********************************
gulp.task('sass', function() {
return gulp.src('src/scss/**/*.scss')
.pipe(plumber())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(autoprefixer({
browsers: ['last 3 versions'],
}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/css'))
.pipe(connect.reload());
});
// ***********************************
// GULP IMAGE
// ***********************************
gulp.task('image', function() {
gulp.src('src/img/**/*')
.pipe(imagemin())
.pipe(gulp.dest('dist/img'))
});
// ***********************************
// GULP SCRIPT
// ***********************************
gulp.task('script', function() {
gulp.src('src/js/**/*.js')
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist/js'))
.pipe(connect.reload());
});
// ***********************************
// ClEAN
// ***********************************
gulp.task('clean', function() {
return del(['dist/**/*']);
});
// ***********************************
// GULP CONNECT
// ***********************************
gulp.task('connect', function() {
connect.server({
root: 'dist',
livereload: true
});
});
// *************************************
// GULP WATCH
// *************************************
gulp.task('watch', function() {
gulp.watch('src/*.jade', ['jade']);
gulp.watch('src/scss/*.scss', ['sass']);
gulp.watch('src/js/*.js', ['script']);
});
// *************************************
// GULP
// *************************************
gulp.task('default', ['watch', 'connect']);