-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
52 lines (45 loc) · 1.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
var gulp = require('gulp');
var gutil = require('gulp-util');
var notify = require('gulp-notify');
var sass = require('gulp-ruby-sass');
var autoprefix = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var include = require('gulp-include');
var uglify = require('gulp-uglify');
var shell = require('gulp-shell');
var sassDir = 'src/assets/sass';
var jsDir = 'src/assets/js';
var outputDir = 'public/assets';
gulp.task('main-css', function(){
return gulp.src(sassDir + '/main.sass')
.pipe(sass())
.on('error', handleSassError)
.pipe(autoprefix('last 3 version'))
.pipe(minifyCSS({keepSpecialComments:0}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(outputDir + '/css'))
.pipe(notify('compiled'));
});
gulp.task('main-js', function(){
return gulp.src(jsDir + '/main.js')
.pipe(include())
.pipe(uglify())
.on('error', handleJsError)
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(outputDir + '/js'))
.pipe(notify('compiled'));
});
gulp.task('watch', function(){
gulp.watch(sassDir + '/**/*.sass', ['main-css']);
gulp.watch(jsDir + '/**/*.js', ['main-js']);
});
gulp.task('default', ['main-css', 'main-js', 'watch']);
function handleJsError(err, line) {
gulp.src(jsDir + '/main.js').pipe(notify(err + ' ' + line));
this.emit('end');
}
function handleSassError(err) {
gulp.src(sassDir + '/main.sass').pipe(notify(err));
this.emit('end');
}