-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
75 lines (59 loc) · 1.75 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
// *************************************
// Gulpfile
// *************************************
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var browserSync = require('browser-sync');
// -------------------------------------
// Options
// -------------------------------------
var options = {
html: {
files : '*.html'
},
sass: {
files : 'src/scss/**/*.scss',
destination : 'theme/css'
},
scripts: {
files : 'src/js/**/*.js',
destination : 'theme/js'
}
};
// -------------------------------------
// Task: Serve
// -------------------------------------
gulp.task('serve', ['styles', 'scripts'], function() {
browserSync.init({
server: './'
});
gulp.watch(options.sass.files, ['styles']);
gulp.watch(options.scripts.files, ['scripts']).on('change', browserSync.reload);
gulp.watch(options.html.files).on('change', browserSync.reload);
});
// -------------------------------------
// Task: Sass
// -------------------------------------
gulp.task('styles', function() {
return gulp.src(options.sass.files)
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer('last 3 versions'))
.pipe(gulp.dest(options.sass.destination))
.pipe(browserSync.stream());
});
// -------------------------------------
// Task: Scrits
// -------------------------------------
gulp.task('scripts', function() {
return gulp.src(options.scripts.files)
.pipe(uglify())
.pipe(gulp.dest(options.scripts.destination))
.pipe(browserSync.stream());
});
// -------------------------------------
// Task: Default
// -------------------------------------
gulp.task('default', ['serve']);