forked from prajjwaldimri/attendance-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (47 loc) · 1.3 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
let gulp = require('gulp');
// Gulp Plugins
let sass = require('gulp-sass');
let uglify = require('gulp-uglify');
let cleanCSS = require('gulp-clean-css');
let sourceMaps = require('gulp-sourcemaps');
let imagemin = require('gulp-imagemin');
let babel = require('gulp-babel');
// Convert and minify sass files
gulp.task('sass', function () {
return gulp
.src('./src/sass/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(sourceMaps.init())
.pipe(cleanCSS())
.pipe(sourceMaps.write())
.pipe(gulp.dest('./dist/css'));
});
// Minify JS files
gulp.task('uglify', function () {
gulp
.src('./src/js/*.js')
.pipe(babel())
.pipe(
uglify().on('error', function (err) {
console.log(err);
this.emit('end');
})
)
.pipe(gulp.dest('./dist/js'));
});
// Minify Images
gulp.task('imgmin', function () {
gulp
.src('./src/img/*')
.pipe(imagemin())
.pipe(gulp.dest('./dist/img'));
});
// Watch files for changes
gulp.task('watch', function () {
gulp.watch('./src/js/*.js', ['uglify']);
gulp.watch('./src/sass/*.scss', ['sass']);
gulp.watch('./src/img/*.*', ['imgmin']);
gulp.watch('./libs/materialize-src/*.*', ['materialize-css']);
});
// Default Task that runs all other tasks
gulp.task('default', ['sass', 'uglify', 'imgmin', 'watch']);