Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const browsersync = require("browser-sync");
  2. const gulp = require("gulp");
  3. const phpConnect = require('gulp-connect-php');
  4.  
  5. // PHP connect
  6. function connectsync() {
  7. phpConnect.server({
  8. // a standalone PHP server that browsersync connects to via proxy
  9. port: 8000,
  10. keepalive: true,
  11. base: "dist"
  12. },
  13. function () {
  14. browsersync({
  15. proxy: '127.0.0.1:8000'
  16. });
  17. });
  18. }
  19.  
  20. // BrowserSync Reload
  21. function browserSyncReload(done) {
  22. browsersync.reload();
  23. done();
  24. }
  25.  
  26. function php() {
  27. return gulp.src("./public_html/**/*.php")
  28. .pipe(gulp.dest("./dist"));
  29. }
  30.  
  31. // Watch files
  32. function watchFiles() {
  33. gulp.watch("public_html/**/*.php", gulp.series(php, browserSyncReload));
  34. }
  35.  
  36. const watch = gulp.parallel([watchFiles, connectsync]);
  37.  
  38. exports.default = watch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement