Skip to content

Instantly share code, notes, and snippets.

@DavidPeralvarez
Created November 6, 2018 11:30
Show Gist options
  • Save DavidPeralvarez/35b1355e8a1833a544f4d884b72b8595 to your computer and use it in GitHub Desktop.
Save DavidPeralvarez/35b1355e8a1833a544f4d884b72b8595 to your computer and use it in GitHub Desktop.
Temas de WordPress + Gulp + Browsersync
/*
- Compilar código LESS
- Añadir vendor prefixes
- Minificar código CSS resultante
- Observar los archivos para ejecutar las tareas de forma automática
- Recargar automáticamente el navegador
*/
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
cleancss = require('gulp-clean-css'),
rename = require('gulp-rename'),
less = require('gulp-less'),
browserSync = require('browser-sync').create();
gulp.task('servir', ['estilos'], function(){
browserSync.init({
proxy: 'cursogulp.local',
open: false
});
gulp.watch('./less/**/*.less', ['estilos']);
gulp.watch(['./*.php','./inc/*.php','./template-parts/*.php']).on('change', browserSync.reload);
});
gulp.task('estilos', function(){
return gulp.src('./less/app.less')
.pipe(less().on('error', function(err){
console.log(err);
}))
.pipe(autoprefixer({
browsers: ['last 4 versions']
}))
.pipe(cleancss())
.pipe(rename('./style.css'))
.pipe(gulp.dest('./'))
.pipe(browserSync.stream())
});
gulp.task('default', ['servir']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment