-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (74 loc) · 1.88 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
var gulp = require('gulp');
var jade = require('gulp-jade');
var sass = require('gulp-sass');
var prettify = require('gulp-prettify');
var rename = require('gulp-rename');
var minify = require('gulp-csso');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var shell = require('gulp-shell');
var browserSync = require('browser-sync');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var cssnext = require('postcss-cssnext');
var paths = {
'html': 'src/',
'scss': 'src/css/',
'img': 'src/images/',
'dist': 'dist/',
'css': 'dist/css/'
}
gulp.task('bs', function() {
browserSync.init({
server: {
baseDir: paths.dist,
index: 'index.html'
},
notify: true
});
});
gulp.task('html', function() {
return gulp.src([
paths.html + '**/*.jade',
'!' + paths.html + '**/_*.jade'
])
.pipe(jade())
.pipe(gulp.dest(paths.dist));
});
gulp.task('prettify', ['html'], function() {
return gulp.src(paths.dist + '**/*.html')
.pipe(prettify({
brace_style: 'collapse',
indent_size: 2,
indent_char: ' '
}))
.pipe(gulp.dest(paths.dist))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('scss', function() {
var processors = [
cssnext()
];
return gulp.src(paths.scss + '**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'expanded',
includePaths: require('node-reset-scss').includePath
}))
.on('error', function(err) {
console.log(err.message);
})
.pipe(postcss(processors))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.css))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('watch', function() {
gulp.watch([paths.html + '**/*.jade'], ['prettify']);
gulp.watch([paths.scss + '**/*.scss'], ['scss']);
});
gulp.task('default', ['bs', 'prettify', 'scss', 'watch']);