0
Browser Syncを使用してファイルの変更を監視するPHPサーバをローカルに作成したいとします。ブラウザで新しいタブを開き、index.phpファイルの内容を表示したいと思います。マイgulpfile.js:PHPサーバとブラウザ同期のためのgulpfile.jsの設定
var gulp = require('gulp');
var browserSync = require('browser-sync').create(); //reloading while saving file
var php = require('gulp-connect-php'); //for PHP server
// ------------------------------------------------- //
// --------- Server and watching for changes --------//
// ------------------------------------------------- //
gulp.task('php', function() {
php.server({ base: 'src', port: 8080, keepalive: true, hostname: 'localhost'});
});
gulp.task('browser-sync',['php'], function() {
browserSync.init({
proxy: '127.0.0.1',
port: 8080
});
});
gulp.task('htmlServer', function() {
gulp.src(['src/*.+(html|ico|php)'])
.pipe(browserSync.reload({
stream: true
}));;
});
gulp.task('stylesServer', function() {
gulp.src(['src/styles/*.css'])
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('jsServer', function() {
gulp.src(['src/scripts/*.js'])
.pipe(browserSync.reload({
stream: true
}));
});
// --------- wrapped together --------- //
gulp.task('server', ['browser-sync','php','htmlServer','stylesServer','jsServer'], function() {
gulp.watch('src/styles/*.css',['stylesServer']);
gulp.watch('src/*.+(html|php)',['htmlServer']);
gulp.watch('src/scripts/*.js',['jsServer']);
});
しかし、私はそれがブラウザで新しいタブを飛び出して、画面上のようにロードし続けてゴクゴクサーバータスクを起動するとき:
誰かが私を助けることができますか?私は多くのチュートリアルを見ていましたが、何も働かず、私はもっと混乱したくありません。あなたの助けをあらかじめありがとうございます。