-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·58 lines (43 loc) · 1.26 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
/*
gulpfile.js
Contains:
Autoprefixer, js_minify, error_handling and browserSync
===========
*/
var gulp = require('gulp');
var sass = require('gulp-sass');
var scripts = require('gulp-uglify'); // js minify
var prefix = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
// compile SASS into CSS task
gulp.task ('sass', function() {
return gulp.src('app/scss/**/*.scss') // glob gets any file with .scss
.pipe(sass()) // Converts Sass to CSS with gulp-sass
.on('error', console.error.bind(console)) //error handling
.pipe(prefix('last 4 versions'))
.pipe(gulp.dest('app/css'));
});
// runs sass task
// do browserSync reload
gulp.task ('sass-watch', ['sass'], browserSync.reload);
// gulp minify js
gulp.task ('scripts', function() {
return gulp.src('app/js/**/*.js')
.pipe(scripts())
.on('error', console.error.bind(console)) //error handling
.pipe(gulp.dest('app/minjs'));
});
// watch task
// rebuilds everytime a change is made
gulp.task('watch', function() {
browserSync({
//port : 9002,
server: {
baseDir: 'app/'
}
});
gulp.watch('app/scss/**/*.scss', ['sass-watch']);
gulp.watch('app/js/**/*.js', ['scripts']);
});
// default build task
gulp.task('default', ['sass', 'scripts', 'watch']);