-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathgulpfile.js
92 lines (79 loc) · 2.36 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
86
87
88
89
90
91
92
//
// Gulpfile
//
var gulp = require('gulp'),
sass = require('gulp-sass'),
changed = require('gulp-changed'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
del = require('del'),
concat = require('gulp-concat'),
cssnano = require('gulp-cssnano'),
uglify = require('gulp-uglifyjs'),
cache = require('gulp-cache'),
imagemin = require('gulp-imagemin'),
imageminJpegRecompress = require('imagemin-jpeg-recompress'),
pngquant = require('imagemin-pngquant'),
browserSync = require('browser-sync').create();
//
// Gulp plumber error handler - displays if any error occurs during the process on your command
//
function errorLog(error) {
console.error.bind(error);
this.emit('end');
}
//
// SASS - Compile SASS files into CSS
//
gulp.task('sass', function () {
// Theme
gulp.src('./assets/include/scss/**/*.scss')
.pipe(changed('./assets/css/'))
.pipe(sass({ outputStyle: 'expanded' }))
.on('error', sass.logError)
.pipe(autoprefixer([
"last 1 major version",
">= 1%",
"Chrome >= 45",
"Firefox >= 38",
"Edge >= 12",
"Explorer >= 10",
"iOS >= 9",
"Safari >= 9",
"Android >= 4.4",
"Opera >= 30"], { cascade: true }))
.pipe(gulp.dest('./assets/css/'))
.pipe(browserSync.stream());
});
//
// BrowserSync (live reload) - keeps multiple browsers & devices in sync when building websites
//
//
gulp.task('serve', function() {
browserSync.init({
files: "./*.html",
startPath: "./index.html",
server: {
baseDir: "./",
routes: {},
middleware: function (req, res, next) {
if (/\.json|\.txt|\.html/.test(req.url) && req.method.toUpperCase() == 'POST') {
console.log('[POST => GET] : ' + req.url);
req.method = 'GET';
}
next();
}
}
})
});
//
// Gulp Watch and Tasks
//
//
gulp.task('watch', function() {
gulp.watch('./assets/include/scss/**/*.scss', ['sass']);
gulp.watch('./html/**/*.html').on('change', browserSync.reload);
gulp.watch('./documentation/**/*.html').on('change', browserSync.reload);
});
// Gulp Tasks
gulp.task('default', ['watch', 'sass', 'serve'])