如何使用GULP运行PHP文件?

时间:2018-01-22 16:00:28

标签: php gulp gulp-connect-php

到目前为止,我已经设置了我的gulpfile.js并安装了我所知道的所有依赖项。是否存在文件路径问题?我正在尝试"使用" GULP为了运行我的PHP文件并最终能够将其投入生产。

这是我的GULP和JSON文件。到目前为止,我发现gulp-connect-php是一个任务管理器,但我不确定是否存在语法问题。

errMsg:拒绝连接 - gulp似乎正在编译和运行"罚款"减去屏幕上没有显示的事实。

const gulp = require('gulp'),
php  = require('gulp-connect-php');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const babel = require('gulp-babel');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;

gulp.task('php', function() {
php.server({ base: 'app', port: 8010, keepalive: true});
});

gulp.task('browser-sync',['php'], function() {
browserSync.init({
proxy: '127.0.0.1:8010',
port: 8080,
open: true,
notify: false
});
});

gulp.task('default', ['browser-sync'], function () {
gulp.watch(['build/*.php'], [reload]);
});

gulp.task('styles', () => {
return gulp.src('./dev/styles/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer('last 2 versions', 'safari 5', 'ie 8', 'ie 9', 
'opera 12.1'))
.pipe(concat('style.css'))
.pipe(gulp.dest('./assets/styles/main.css'))
 });

gulp.task('watch', () => {
gulp.watch('./dev/styles/**/*.scss', ['styles']);
gulp.watch('./assets/js/main.js', ['scripts']);
gulp.watch('*.html', reload);
});

gulp.task('scripts', () => {
gulp.src('./dev/scripts/main.js')
 .pipe(babel({
presets: ['es2015']
}))
 .pipe(gulp.dest('./public/scripts'))
 .pipe(reload({stream: true}));
});

// gulp.task('browser-sync', () => {
//   browserSync.init({
//     server: '.'  
//   })
// });




gulp.task('default', ['php','browser-sync','styles', 'scripts', 
'watch']);



{
 "name": "psd-gulp-setup",
 "version": "1.0.0",
 "description": "gulp php test setup",
 "main": "index.js",
 "dependencies": {},
 "devDependencies": {
 "babel-core": "^6.26.0",
"babel-preset-env": "^1.6.1",
"browser-sync": "^2.23.5",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^4.1.0",
"gulp-babel": "^7.0.0",
"gulp-concat": "^2.6.1",
"gulp-connect-php": "^1.0.1",
"gulp-sass": "^3.1.0"
 },
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
 "repository": {
 "type": "git",
 "url": "git+https://github.com/Robinhoeh/jb-gulp-test.git"
 },
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Robinhoeh/jb-gulp-test/issues"
 },
 "homepage": "https://github.com/Robinhoeh/jb-gulp-test#readme"
 }

0 个答案:

没有答案