-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (48 loc) · 1.51 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
'use strict'
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var cleanCSS = require('gulp-clean-css');
var htmlmin = require('gulp-htmlmin');
var paths = {
src: {
style: './scss/**/*.scss',
scripts: './scripts/*.js',
html: './templates/**/*.html'
},
dest: {
style: './public/style',
scripts: './public/js',
html: './templates_minified',
}
}
function errorHandler (error) {
console.log('\n\n\n----------------------------------------------------\n Begin error\n');
console.error(error.toString());
console.log('\n\n\n----------------------------------------------------\n end of error\n');
this.emit('end');
}
gulp.task('css', function () {
return gulp.src(paths.src.style)
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS({compatibility: 'ie9'}))
.on('error', errorHandler)
.pipe(gulp.dest(paths.dest.style))
});
gulp.task('js', function() {
return gulp.src(paths.src.scripts)
.pipe(uglify())
.on('error', errorHandler)
.pipe(gulp.dest(paths.dest.scripts));
});
gulp.task('htmlmin', function () {
return gulp.src(paths.src.html)
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest(paths.dest.html));
});
gulp.task('watch', function () {
gulp.watch(paths.src.style, ['css'])
gulp.watch(paths.src.scripts, ['js'])
gulp.watch(paths.src.html, ['htmlmin'])
});
gulp.task('default', ['css', 'js', 'htmlmin']);