D
D
DenJel2015-08-06 09:45:10
PHP
DenJel, 2015-08-06 09:45:10

Gulp+PHP local server+wordpress?

Hello, when creating a template for wordpress, I first layout on the local node.js server, then I launch wordpress on MAMP and pull the layout. How to remove the intermediate stage of layout? How to set up gulp directly under PHP server? So that when layout it refreshes the page
Here is my Gulp file:

var gulp = require('gulp'),
stylus = require('gulp-stylus'),
webserver = require('gulp-webserver'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
csso = require('gulp-csso'),
autoprefixer = require('autoprefixer-stylus'),
fontmin = require('gulp-fontmin'),
clean = require('gulp-clean'),
replace = require('gulp-replace'),
spritesmith = require('gulp.spritesmith');

/*****************
***** STYLUS *****
******************/
gulp.task('stylus', function() {
 return gulp.src(['./main.styl', './main_media.styl'])
 .pipe(plumber())
 .pipe(stylus({compress: false, use: autoprefixer()}))
 // .pipe(csso())
 .pipe(gulp.dest('./css'));
});

/****************
***** FONTS *****
*****************/

gulp.task('fontmin', function() {
    return gulp.src('./fonts/ttf/*.ttf')
        .pipe(fontmin())
        .pipe(gulp.dest('./fonts/'));
});

gulp.task('fonts-concat', ['fontmin'], function() {
  return gulp.src('./fonts/*.css')
    .pipe(concat('fonts.css'))
    .pipe(gulp.dest('./css/fonts-before/'));
});

gulp.task('replace-fonts', ['fonts-concat'], function(){
  return gulp.src(['./css/fonts-before/fonts.css'])
    .pipe(replace('url("', 'url("../fonts/'))
    .pipe(gulp.dest('./css/'));
});

gulp.task('fonts', ['replace-fonts'], function() {
    return gulp.src(['./fonts/*.css', './css/fonts-before/'], {read: false})
        .pipe(clean());
});



/******************
***** SPRITES *****
*******************/
var pages = [
'index'
]

gulp.task('sprite', function() {
  for (var i = 0; i < pages.length; i++){
    var spriteData = 
          gulp.src('./img/sprite/before/'+pages[i]+'/*.*') // путь, откуда берем картинки для спрайта
          .pipe(spritesmith({
            imgName: 'sprite_'+pages[i]+'.png',
            cssName: 'sprite_'+pages[i]+'.styl',
            cssFormat: 'stylus',
            algorithm: 'binary-tree',
            padding: 1,
            cssTemplate: 'stylus.template.mustache',
            cssVarMap: function(sprite) {
              sprite.name = 's-' + sprite.name
            }
          }));
      spriteData.img.pipe(gulp.dest('./img/sprite/')); // путь, куда сохраняем картинку
      spriteData.css.pipe(gulp.dest('./stylus/')); // путь, куда сохраняем стили
    }
  });


/************************************
***** WEBSERVER, WATCH, DEFAULT *****
*************************************/
gulp.task('webserver', function() {
  gulp.src('./')
  .pipe(webserver({
    livereload: true,
    directoryListing: true,
    open: true,
    fallback: 'index.html'
  }));
});

gulp.task('watch', function() {
  gulp.watch('./**/*.styl', ['stylus']);
  gulp.watch('./img/sprite/before/**/*', ['sprite']);
});

gulp.task('default', ['watch', 'webserver']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
faragly, 2015-08-06
@faragly

Maybe this will help - gulp-connect-php . While it won't solve your expectations, it will only make working with php possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question