-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (49 loc) · 1.39 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var autoprefixer = require('gulp-autoprefixer');
const PATH_SASS_FILES = 'sass/*.sass';
const PATH_HTML_FILES = '**/*.html';
const PATH_JS_FILES = 'js/**/*.js';
/*
gulp.task('task-name', function () {
return gulp.src('source-files') // Get source files with gulp.src
.pipe(aGulpPlugin()) // Sends it through a gulp plugin
.pipe(gulp.dest('destination')) // Outputs the file in the destination folder
})
*/
gulp.task('sass', function(){
return gulp.src(PATH_SASS_FILES)
.pipe(sass()) // Converts Sass to CSS with gulp-sass
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({
stream: true
}))
});
/*
// Gulp watch syntax
gulp.watch('files-to-watch', ['tasks', 'to', 'run']);
*/
gulp.task('watch', ['browserSync', 'sass'], function(){
gulp.watch(PATH_SASS_FILES, ['sass']);
// Reloads the browser whenever HTML or JS files change
gulp.watch(PATH_HTML_FILES, browserSync.reload);
gulp.watch(PATH_JS_FILES, browserSync.reload);
});
/*
gulp.task('watch', ['array', 'of', 'tasks', 'to', 'complete','before', 'watch'], function (){
// ...
})
*/
gulp.task('browserSync', function(){
browserSync.init({
server: {
baseDir: '.'
}
})
})
gulp.task('default', ['watch']);