-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGulpfile.js
More file actions
54 lines (47 loc) · 1.47 KB
/
Copy pathGulpfile.js
File metadata and controls
54 lines (47 loc) · 1.47 KB
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
'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'),
historyApiFallback = require('connect-history-api-fallback');
// Servidor web de desarrollo
gulp.task('server', function() {
connect.server({
root: './app',
// hostname: '0.0.0.0',
// port: 8080,
livereload: true,
middleware(server, opt) {
return [historyApiFallback()];
},
});
});
// Busca errores en el JS y nos los muestra por pantalla
gulp.task('jshint', function() {
return gulp.src(['./app/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('./app/stylesheets/main.styl')
.pipe(stylus({ use: nib() }))
.pipe(gulp.dest('./app/stylesheets'))
.pipe(connect.reload());
});
// Recarga el navegador cuando hay cambios en el HTML
gulp.task('html', function() {
gulp.src('./app/**/*.html')
.pipe(connect.reload());
});
// Vigila cambios que se produzcan en el código
// y lanza las tareas relacionadas
gulp.task('watch', function() {
gulp.watch(['./app/scripts/**/*.js', './Gulpfile.js'], ['jshint']);
gulp.watch(['./app/**/*.html'], ['html']);
gulp.watch(['./app/stylesheets/**/*.styl'], ['css']);
});
gulp.task('default', ['server', 'watch']);