-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
67 lines (59 loc) · 1.75 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
compass = require('gulp-compass'),
minifyCSS = require('gulp-minify-css'),
imagemin = require('gulp-imagemin'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
glob = require("glob"),
uncss = require('gulp-uncss'),
livereload = require('gulp-livereload'),
checkCSS = require( 'gulp-check-unused-css' ),
critical = require('critical');
gulp.task('styles', function() {
gulp.src('assets/devel/sass/style.scss')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(compass({
css: 'assets/build/css',
sass: 'assets/devel/sass'
}))
.on('error', function(err) {
// Would like to catch the error here
})
.pipe(minifyCSS())
.pipe(gulp.dest('assets/build/css'))
.pipe(livereload());
});
gulp.task('image', function() {
gulp.src('assets/devel/images/**/*')
.pipe(imagemin())
.pipe(gulp.dest('assets/build/img'));
});
gulp.task('unusecss', function() {
// gulp.src('assets/bulid/css/style.css')
// .pipe(uncss({
// html: glob.sync('assets/devel/html/*.html')
// }))
// .pipe(gulp.dest('assets/devel/uncss'));
// gulp
// .src([ 'assets/bulidcss/css/style.css', 'assets/devel/html/*.html' ])
// .pipe( checkCSS() );
critical.generateInline({
base: 'assets/devel/html',
src: 'home.html',
width: 320,
height: 480,
htmlTarget: 'home.html',
styleTarget: 'assets/build/css/style.css',
minify: true
});
});
gulp.task('watch', function(){
var server = livereload();
gulp.watch('assets/devel/sass/**/*.scss', ['styles']);
});
gulp.task('default', ['styles', 'image', 'watch']);