-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (77 loc) · 2.44 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
77
78
79
80
81
82
83
84
85
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const sass = require('gulp-sass');
const cssnano = require('gulp-cssnano');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const babel = require('gulp-babel');
const imagemin = require('gulp-imagemin');
const size = require('gulp-size');
const browserSync = require('browser-sync').create();
const changed = require('gulp-changed');
const surge = require('gulp-surge');
//CSS FUNCTION
gulp.task('css', function() {
return gulp.src('./css/*.scss')
.pipe(plumber({
errorHandler: function(error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(cssnano())
.pipe(sourcemaps.write('./'))
.pipe(size())
.pipe(gulp.dest('./css/'))
.pipe(browserSync.stream());
});
gulp.task('js', function() {
return gulp.src('./js/*.js')
.pipe(plumber({
errorHandler: function(error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(babel({
presets: ['es2015']
}))
.pipe(size())
.pipe(gulp.dest('./js/dist'))
.pipe(browserSync.stream());
});
gulp.task('img', function() {
return gulp.src('./images/original/*')
.pipe(changed('./images/'))
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(size())
.pipe(gulp.dest('./images/'))
.pipe(browserSync.stream());
});
gulp.task('watch', function() {
gulp.watch('./css/*.scss', ['css']);
gulp.watch('./js/*.js', ['js']);
gulp.watch('./images/*', ['img']);
});
//serve browser
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: './'
}
});
gulp.watch('*.html').on('change', browserSync.reload);
});
gulp.task('deploy',function () {
return surge({
project: '.', // Path to your static build directory
domain: 'ufc-ranking.surge.sh' // Your domain or Surge subdomain
});
});
gulp.task('default', ['css', 'js', 'img', 'watch', 'serve']);