-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
76 lines (67 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
76
/**
* Created by SelcetStudio on 1/23/16.
*/
// Requires the gulp-sass plugin
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
size = require('gulp-size'),
sourcemaps = require('gulp-sourcemaps'),
watch = require('gulp-watch'),
merge = require('merge-stream'),
del = require('del');
// This is an object which defines paths for the styles.
// The folder, files to look for and destination are all required for sass
var paths = {
styles: {
name: 'app',
src: './app/scss',
files: './app/scss/**/*.scss',
dest: './app/css/',
del: 'app/css/**/*'
}
};
// Clean task
gulp.task('clean', function (cb) {
del.sync([
paths.styles.del,
// we don't want to clean this file though so we negate the pattern
'!app/css/deploy.txt'
], cb);
});
// BrowserSync task
gulp.task('browserSync', function() {
browserSync({
server: {
baseDir: 'app'
}
})
});
// Sass compilation
gulp.task('sass', function () {
gulp.src(paths.styles.files)
.pipe(sourcemaps.init())
.pipe(sass.sync({
sourceMap: true,
sourceComments: 'normal'
}).on('error', sass.logError))
.pipe(sourcemaps.write('maps'))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest(paths.styles.dest))
.pipe(browserSync.reload({
stream: true
}))
});
// Sass watch
gulp.task('sass:watch', function () {
gulp.watch(paths.styles.files, ['sass'])
});
//Watch task
gulp.task('default', ['browserSync', 'sass', 'sass:watch'], function (){
// Reloads the browser whenever Scss files change
gulp.watch(paths.styles.files, ['sass']);
// Reloads the browser whenever HTML files change
gulp.watch('app/*.html', browserSync.reload);
// Reloads the browser whenever JS files change
gulp.watch('app/scripts/**/*.js', browserSync.reload);
});