forked from jggomez/blogeek-platzi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (72 loc) · 1.86 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')
var stylus = require('gulp-stylus')
var browserSync = require('browser-sync').create()
var useref = require('gulp-useref')
var gulpIf = require('gulp-if')
var imagemin = require('gulp-imagemin')
var cache = require('gulp-cache')
var del = require('del')
var runSequence = require('run-sequence')
var htmlmin = require('gulp-htmlmin')
var minifyCSS = require('gulp-minify-css')
// Tareas para el desarrollo
// Get one .styl file and render
gulp.task('stylus', function () {
return gulp
.src('app/stylus/*.styl')
.pipe(stylus())
.pipe(gulp.dest('app/css'))
.pipe(
browserSync.reload({
stream: true
})
)
})
gulp.task('browserSync', () => {
browserSync.init({
server: {
baseDir: 'public',
port: 4000
}
})
})
gulp.task('watch', ['browserSync', 'stylus'], () => {
// gulp.watch('app/stylus/*.styl', ['stylus']);
gulp.watch('public/*.html', browserSync.reload)
gulp.watch('public/**/*.js', browserSync.reload)
})
gulp.task('default', callback => {
runSequence(['browserSync', 'watch'], callback)
})
//
// Tareas para el deploy
gulp.task('useref', () => {
return gulp
.src('app/**/*.html')
.pipe(useref())
.pipe(gulpIf('*.js', minify({ mangle: false })))
.pipe(gulpIf('*.css', minifyCSS()))
.pipe(gulpIf('*.html', htmlmin({ collapseWhitespace: true })))
.pipe(gulp.dest('dist'))
})
gulp.task('images', () => {
return gulp
.src('app/imagenes/**/*.+(png|jpg|gif|svg)')
.pipe(
cache(
imagemin({
interlaced: true
})
)
)
.pipe(gulp.dest('dist/imagenes'))
})
gulp.task('fonts', () => {
return gulp.src('app/fonts/**/*').pipe(gulp.dest('dist/fonts'))
})
gulp.task('clean', () => {
return del.sync('dist')
})
gulp.task('build', callback => {
runSequence('clean', 'stylus'[('useref', 'images', 'fonts')], callback)
})