Completed
Push — master ( c5e908...a0379d )
by Ankit
03:06
created

gulpfile.js (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
var gulp = require('gulp'),
2
    gutil = require('gulp-util'),
3
    uglify = require('gulp-uglify'),
4
    concat = require('gulp-concat');
5
    connect = require('gulp-connect-php'),
6
    browserSync = require('browser-sync'),
7
    rename = require('gulp-rename');
0 ignored issues
show
The variable rename seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.rename.
Loading history...
8
9
var jsSources = ['js/*.js'],
10
    phpSources = ['*.php'];
11
12
13
14
15
16
gulp.task('log', function() {
17
  gutil.log('== My First Task ==')
18
});
19
20
// gulp.task('copy', function() {
21
//   gulp.src('index.html')
22
//   .pipe(gulp.dest(outputDir))
23
// });
24
25
// gulp.task('sass', function() {
26
//   gulp.src(sassSources)
27
//   .pipe(sass({style: 'expanded'}))
28
//     .on('error', gutil.log)
29
//   .pipe(gulp.dest('assets'))
30
//   .pipe(connect.reload())
31
// });
32
33
// gulp.task('coffee', function() {
34
//   gulp.src(coffeeSources)
35
//   .pipe(coffee({bare: true})
36
//     .on('error', gutil.log))
37
//   .pipe(gulp.dest('scripts'))
38
// });
39
40
// gulp.task('js', function() {
41
//   gulp.src('js/index.js')
42
//   .pipe(concat('script.js'))
43
//   .pipe(rename({ suffix: '.min' }))
44
//   .pipe(uglify())
45
//   .pipe(gulp.dest('js'))
46
// });
47
48
// gulp.task('js2', function() {
49
//   gulp.src('js/index.js')
50
//   .pipe(concat('script.js'))
51
//   .pipe(gulp.dest('js'))
52
//   .pipe(rename({ suffix: '.min' }))
53
//   .pipe(uglify())
54
//   .pipe(gulp.dest('js'))
55
// });
56
57
58
59
// gulp.task('watch', function() {
60
61
//   livereload.listen();
62
//   // gulp.watch('*.php').on('change', livereload.reload);
63
64
//     gulp.watch('*.php').on('change', function(file) {
65
//           gutil.log("Changed" + file.path);
66
//           livereload.changed(file.path);
67
//       });
68
69
// });
70
71
72
// gulp.task('connect', function() {
73
//   connectPHP.server({
74
//     hostname: '127.0.0.1',
75
//     bin: 'C:/xampp/php/php.exe',
76
//     ini: 'C:/xampp/php/php.ini',
77
//     port: 3000,
78
//     base: '.',
79
//     livereload: true
80
//   // }, function () {
81
//   //         browserSync.init({
82
//   //           proxy: "localhost:3000"
83
//   //   });
84
//   });
85
// });
86
87
88
89
90
gulp.task('connect', function() {
91
  connect.server({
92
    hostname: '127.0.0.1',
93
    port: 3000,
94
    base: '.'
95
  }, function() {
96
    browserSync({
97
      proxy: '127.0.0.1:3000',
98
      port: 8888
99
  });
100
  });
101
});
102
103
gulp.task('watch', function() {
104
  gulp.watch(['views/*.php']).on('change', browserSync.reload);
105
});
106
107
108
//task that fires up browserSync proxy after connect server has started
109
// gulp.task('browser-sync',['connect'], function() {
110
111
// });
112
113
114
//default task that runs task browser-sync ones and then watches php files to change. If they change browserSync is reloaded
115
// gulp.task('default', ['browser-sync'], function () {
116
//   gulp.watch(['*.php'], browserSync.reload);
117
// });
118
119
gulp.task('default', ['connect', 'watch']);