-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (73 loc) · 1.65 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
var csso = require('gulp-csso');
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var jade = require('gulp-jade');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var plumber = require('gulp-plumber');
//sass
gulp.task('sass', function() {
return gulp.src('src/scss/**/*.scss')
.pipe(plumber())
.pipe(sass())
.pipe(autoprefixer({
browsers: ['last 5 versions'],
cascade: false
}))
.pipe(gulp.dest('dist/css'))
.pipe(rename({
suffix: '.min'
}))
.pipe(autoprefixer({
browsers: ['> 0%'],
cascade: false
}))
.pipe(csso())
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({
stream: true
}));
});
//browserSync
gulp.task('browserSync', function() {
browserSync({
server: {
baseDir: 'dist'
},
});
});
//jade
gulp.task('jade', function() {
return gulp.src('src/templates/**/!(_)*.jade')
.pipe(plumber())
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({
stream: true
}));
});
//scripts
gulp.task('uglify', function() {
return gulp.src('src/scripts/**/*.js')
.pipe(plumber())
.pipe(gulp.dest('dist/js'))
.pipe(concat('app.min.js'))
.pipe(gulp.dest('dist/js'))
.pipe(uglify({
mangle: false
}))
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('watch', ['browserSync', 'sass', 'jade', 'uglify'], function() {
gulp.watch('src/scss/**/*.scss', ['sass']);
gulp.watch('src/templates/**/*.jade', ['jade']);
gulp.watch('src/scripts/**/*.js', ['uglify']);
});