-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
114 lines (93 loc) · 2.76 KB
/
gulpfile.js
File metadata and controls
114 lines (93 loc) · 2.76 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var cssnano = require('gulp-cssnano');
var imagemin = require('gulp-imagemin');
var cache = require('gulp-cache');
var del = require('del');
var runSequence = require('run-sequence');
const gulpDeployFtp = require('gulp-deploy-ftp');
var php = require('gulp-connect-php'); //for PHP server
gulp.task('sass', function() {
return gulp.src('app/scss/**/*.scss') // Gets all files ending with .scss in app/scss
.pipe(sass())
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('php', function() {
php.server({ base: 'app', port: 8010, keepalive: true});
});
gulp.task('server',['php'], function() { //reload de browser en desarrollo
browserSync.init({
// server: {
// baseDir: 'app',
// },
open: false,
proxy: '127.0.0.1:8010',
port:8080
})
})
gulp.task('phpbuild', function() {
php.server({ base: 'build', port: 8010, keepalive: true});
});
gulp.task('serverbuild', ['phpbuild'], function() { //server de build
browserSync.init({
// server: {
// baseDir: 'build',
// },
proxy: '127.0.0.1:8010',
open: false,
port:9000
})
})
gulp.task('default', ['server', 'sass'], function (){ //crea un server
gulp.watch('app/scss/**/*.scss', ['sass']);
gulp.watch('app/*.html', browserSync.reload);
gulp.watch('app/js/**/*.js', browserSync.reload);
gulp.watch('app/*.php', browserSync.reload);
// Other watchers
})
gulp.task('server_build', ['serverbuild'], function (){ //crea un server de build
gulp.watch('build/*.*', browserSync.reload);
// Other watchers
})
gulp.task('images', function(){ // optimiza imagenes
return gulp.src('app/img/**/*.+(png|jpg|jpeg|gif|svg)')
// Caching images that ran through imagemin
.pipe(cache(imagemin({
interlaced: true
})))
.pipe(gulp.dest('build/img'))
});
gulp.task('copiar', function(){ // hace el build
return gulp.src('app/*.*')
.pipe(useref())
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulpIf('*.js', uglify()))
.pipe(gulp.dest('build'))
});
gulp.task('clean:build', function() { // limpia archivos no usados del build
return del.sync('build');
})
gulp.task('build', function (callback) {
runSequence('clean:build',
['sass', 'copiar', 'images'],
callback
)
})
gulp.task('deploy', function () {
return gulp.src('build/*.*')
.pipe(gulpDeployFtp({
remotePath: '/prueba',
host: '185.28.21.195',
port: 21,
user: 'u924475518',
pass: 'Beto2014'
}))
.pipe(gulp.dest('dest'));
})