-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfileOld.js
129 lines (87 loc) · 2.68 KB
/
gulpfileOld.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// ---------- Dependencies ---------- //
var gulp = require('gulp'),
gutil = require('gulp-util'),
uglifyJS = require('gulp-uglifyjs'),
minifyCSS = require('gulp-minify-css'),
autoprefixer = require('gulp-autoprefixer'),
watch = require('gulp-watch'),
sass = require('gulp-sass'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
ftp = require('vinyl-ftp'),
rename = require('gulp-rename'),
del = require('del'),
livereload = require('gulp-livereload');
// ---------- Output paths ---------- //
var publicDir = './',
sassInput = '2-Presentation/**/*.scss',
sassOutput = './',
jsCoreInput = '3-Logic/2-Frontend/Core/*.js',
jsVendorInput = '3-Logic/2-Frontend/Plugins/*.js',
jsOutput = './'
// ---------- FTP settings ---------- //
var ftpHostName = 'gala-holiday.com',
ftpUserName = 'galaho',
ftpPassword = 'Dj$RV|V*yS',
ftpRemoteDirectory = '/domains/ivanjuras.com/public_html/',
ftpPort = 21,
ftpParallelStreams = 10
// ---------- Other variables ---------- //
var jsSourceMap = false,
sassAutoPrefixerVersion = 'last 2 versions',
serverPort = 3000
// ---------- CSS tasks ---------- //
gulp.task( 'styles', function() {
gulp.src( sassInput )
.pipe( sass() ).on( 'error', handleErrors )
.pipe( autoprefixer ({
browsers:[sassAutoPrefixerVersion]
}))
.pipe( minifyCSS() )
.pipe( gulp.dest( sassOutput ) )
.pipe( livereload({start: true}) )
});
// ---------- Javascript tasks ---------- //
gulp.task( 'scripts', function() {
gulp.src( jsCoreInput )
.pipe( jshint() )
.pipe( jshint.reporter( stylish ) )
.pipe( jshint.reporter('fail') ).on( 'error', function () {
this.emit('end')
})
gulp.src( [ jsVendorInput, jsCoreInput ] )
.pipe( uglifyJS( 'script.min.js', {
mangle: true,
outSourceMap: jsSourceMap
}))
.pipe( gulp.dest( jsOutput ) )
.pipe( livereload({start: true}) )
});
// ---------- Deploy online (FTP) ---------- //
gulp.task( 'deploy', function() {
var conn = ftp.create({
host: ftpHostName,
user: ftpUserName,
password: ftpPassword,
port: ftpPort,
parallel: ftpParallelStreams,
log: gutil.log
});
gulp.src( publicDirDeploy, { base: publicDir, buffer: false } )
.pipe ( conn.differentSize( ftpRemoteDirectory ) )
.pipe ( conn.newer( ftpRemoteDirectory ) )
.pipe ( conn.dest( ftpRemoteDirectory ) )
});
// ---------- Watcher ---------- //
gulp.task( 'watch', function() {
livereload.listen();
gulp.watch( sassInput, ['styles'] );
gulp.watch( jsCoreInput, ['scripts'] );
});
// ---------- Handle errors ---------- //
function handleErrors( error ) {
console.error( error );
this.emit( 'end' );
}
// ---------- Run all tasks ---------- //
gulp.task( 'default', ['styles', 'scripts'] );