-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
101 lines (88 loc) · 2.38 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
93
94
95
96
97
98
99
100
101
//
// Gulpfile
//
var gulp = require('gulp'),
sass = require('gulp-sass'),
changed = require('gulp-changed'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
cssnano = require('gulp-cssnano'),
uglify = require('gulp-uglifyjs'),
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: "./",
server: {
baseDir: "./",
},
})
});
//
// Gulp Watch and Tasks
//
//
gulp.task('watch', function () {
gulp.watch('./assets/include/scss/**/*.scss', ['sass']);
gulp.watch('./*.html').on('change', browserSync.reload);
});
// Gulp Tasks
gulp.task('default', ['watch', 'sass', 'serve']);
//
// CSS minifier - merges and minifies the below given list of Front libraries into one theme.min.css
//
gulp.task('minCSS', function () {
return gulp.src([
'./assets/css/theme.css',
])
.pipe(cssnano())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist/css/'));
});
//
// JavaSript minifier - merges and minifies the below given list of Front libraries into one theme.min.js
//
gulp.task('minJS', function () {
return gulp.src([
'./assets/js/*.js',
])
.pipe(concat('theme.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('dist', ['minCSS', 'minJS']);