Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.