forked from godofredoninja/Mapache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
86 lines (71 loc) · 2.24 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
84
85
// File: Gulpfile.js
'use strict';
var gulp = require('gulp'),
connect = require('gulp-connect'),
stylus = require('gulp-stylus'),
nib = require('nib'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
inject = require('gulp-inject'),
wiredep = require('wiredep').stream,
// pro
uglify = require('gulp-uglify'),
concat = require('gulp-concat');
// Busca errores en el JS y nos los muestra por pantalla
gulp.task('jshint', function() {
return gulp.src('./assets/scripts/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
// Preprocesa archivos Stylus a CSS y recarga los cambios
gulp.task('css', function() {
gulp.src(['./stylus/main.styl'])
.pipe(stylus({
use: nib(),
compress: true }))
.pipe(gulp.dest('./assets/css/'))
.pipe(connect.reload());
});
// Inyecta las librerias que instalemos vía Bower
gulp.task('bower-inject', function () {
gulp.src('default.hbs')
.pipe(wiredep({
optional: 'configuration',
goes: 'here',
}))
.pipe(gulp.dest('./'));
});
// Busca en las carpetas de estilos y javascript los archivos que hayamos creado
// para inyectarlos en el index.html
gulp.task('inject', function() {
var sources = gulp.src(['./assets/scripts/**/*.js','./assets/css/**/*.css']);
return gulp.src('default.hbs')
.pipe(inject(sources, {
read: true,
}))
.pipe(gulp.dest('./'));
});
// Vigila cambios que se produzcan en el código
// y lanza las tareas relacionadas
gulp.task('watch', function() {
gulp.watch(['./stylus/**/*.styl'], ['css', 'inject']);
gulp.watch(['./assets/scripts/**/*.js', './Gulpfile.js'], ['jshint', 'inject']);
});
// js lib.min.js
gulp.task('libmin', function () {
var url = [
'./assets/scripts/jquery.fitvids.js',
'./assets/scripts/jquery.ghostHunter.min.js',
'./assets/scripts/prism.js',
'./assets/scripts/whatsapp-button.js',
'./assets/scripts/main.js'
]
gulp.src(url)
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./assets/js/'))
});
gulp.task('default', ['inject', 'watch']);
gulp.task('bower', ['bower-inject']);
gulp.task('pro', ['libmin']);