-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
80 lines (78 loc) · 1.83 KB
/
gulpfile.js
File metadata and controls
80 lines (78 loc) · 1.83 KB
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
var gulp = require('gulp')
, sass = require('gulp-sass')
, sourcemaps = require('gulp-sourcemaps')
, autoprefixer = require('gulp-autoprefixer')
, imagemin = require('gulp-imagemin')
, browserSync = require('browser-sync').create()
, config = require('./config.js');
/**
* html task
*/
gulp.task('html', function() {
return gulp
.src(config.paths.html.src)
.pipe(browserSync.reload({
stream : true
}));
});
/**
* sass to css task
*/
gulp.task('sass', function() {
return gulp
.src(config.paths.style.src)
.pipe(sourcemaps.init())
.pipe(sass(config.sassOptions)).on('error', sass.logError)
.pipe(autoprefixer(config.autoprefixerOptions))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest(config.paths.style.dist))
.pipe(browserSync.reload({
stream : true
}))
});
/**
* javascript task
*/
gulp.task('js', function() {
return gulp
.src(config.paths.js.src)
.pipe(gulp.dest(config.paths.js.dist))
.pipe(browserSync.reload({
stream : true
}));
});
/**
* images task
*/
gulp.task('images', function() {
return gulp
.src(config.paths.image.src)
.pipe(imagemin())
.pipe(gulp.dest(config.paths.image.dist))
.pipe(browserSync.reload({
stream : true
}));
});
/**
* livereload task
*/
gulp.task('browserSync', function() {
browserSync.init({
server : {
baseDir : './'
}
})
});
/**
* task watch
*/
gulp.task('watch', ['browserSync'], function() {
gulp.watch(config.paths.style.src, ['sass']);
gulp.watch(config.paths.js.src, ['js']);
gulp.watch(config.paths.html.src, ['html']);
gulp.watch(config.paths.image.src, ['images']);
});
/**
* default task
*/
gulp.task('default', ['watch']);