Suppose the site is located locally in openserver for testing in the folder C:\OpenServer\domains\site\
Is it possible to use gulp when writing php-code, changes in the browser were visible without reloading the page?
gulpfile.js
var gulp = require('gulp'), browserSync = require('browser-sync').create(), replace = require('gulp-replace'), gulpif = require('gulp-if'), cache = require('gulp-cache'), del = require('del'), path = require('path'); gulp.task('serve',function () { browserSync.init({ server: '/' }); browserSync.watch('/**/*').on('change', browserSync.reload); }); gulp.task('default',gulp.parallel('serve')); This code gives the error Cannot GET /gulpfile.js is at the root of the site
---------- PS ---------- added code
gulpfile.js
var gulp = require('gulp'), bs = require('browser-sync').create(); gulp.task('serve',function () { bs.init({ proxy: "test", port: 3000 }); }); gulp.task('watch',function () { var watcher = gulp.watch('/*.php'); return watcher.on('change', bs.reload); }); gulp.task('default', gulp.series( 'serve', gulp.parallel('watch'))); D:\OSPanel\domains\test path to the test domain D:\OSPanel\domains\test
The index.php file is in the root of the folder, but nothing changes after edits
Plz tell me how to configure?
those. the server is started under the name http://localhost:3000/ and the index.php file is working, but after editing the changes are not visible, the page does not reload
PS
var gulp = require('gulp'), bs = require('browser-sync').create(); gulp.task('serve',function () { bs.init({ proxy: "http://test", port: 3000 }); }); gulp.task('php',function () { return gulp.src('./*.php') .pipe(gulp.dest('/')) }); gulp.task('watch',function () { var watcher = gulp.watch('./*.php', gulp.series('php')); return watcher.on('change', bs.reload); }); gulp.task('default', gulp.parallel('watch', 'serve')); gives an error message:
[15:00:39] 'php' errored after 96 ms [15:00:39] Error: EPERM: operation not permitted, mkdir 'D:\' tried to add such code in init , but also does not work:
bs.init({ proxy: "http://test", files: ["**/*.php"], port: 3000 });