-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (69 loc) · 2.12 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
82
83
var gulp = require('gulp'),
$ = require('gulp-load-plugins')();
var dirs = {
site: 'docs',
source: 'source'
};
// Compile pug task
gulp.task('pug', function () {
var vNumConfig = {
'value': '%MD5%',
'replaces': [
/#{VERSION_REPLACE}/g
]
};
gulp.src([dirs.source + '/pugs/**/*.pug', '!' + dirs.source + '/pugs/**/_*.pug'])
.pipe($.pug({
pretty: true
}))
.pipe($.versionNumber(vNumConfig))
.pipe(gulp.dest(dirs.site));
});
// SASS + Autoprefixer
gulp.task('sass', function () {
return $.rubySass(dirs.source + '/assets/css/main.sass', {
style: 'compact',
'default-encoding': 'utf-8'
})
.on('error', $.rubySass.logError)
.pipe($.autoprefixer('last 15 versions'))
.pipe(gulp.dest(dirs.site + '/assets/css'));
});
gulp.task('js', function () {
gulp.src([dirs.source + '/assets/js/**/*.js', '!' + dirs.source + '/assets/js/libs/*.js'])
.pipe($.minify({
ext: {
src: '.js',
min: '.js'
},
noSource: true,
ignoreFiles: ['.min.js']
}))
.pipe(gulp.dest(dirs.site + '/assets/js/'));
gulp.src([dirs.source + '/assets/js/libs/*.js'])
.pipe($.concat('libs.js'))
.pipe(gulp.dest(dirs.site + '/assets/js/'));
gulp.src([dirs.source + '/assets/js/*.json'])
.pipe($.jsonMinify())
.pipe(gulp.dest(dirs.site + '/assets/js/'));
});
// Watch task
gulp.task('watch', function () {
gulp.watch(dirs.source + '/pugs/**', ['pug']);
gulp.watch(dirs.source + '/assets/css/**', ['sass']);
gulp.watch(dirs.source + '/assets/js/**', ['js']);
});
// Copia todos os arquivos da pasta assets menos as pastas css e js
gulp.task('copyFiles', function () {
gulp.src([
dirs.source + '/assets/**/*',
'!' + dirs.source + '/assets/css/**',
'!' + dirs.source + '/assets/js/**'
])
.pipe(gulp.dest(dirs.site + '/assets/'));
gulp.src([dirs.source + '/*'])
.pipe(gulp.dest(dirs.site + '/'));
});
// Default GULP task
gulp.task('default', ['copyFiles', 'watch']);
// gulp.task('default', ['copyFiles', 'webserver', 'watch']);