Last active
July 23, 2017 22:40
-
-
Save ViktorAndonov/0c0353be713f11e55cabcbc39f82acf8 to your computer and use it in GitHub Desktop.
Gulp.js for WP Theme Development with SASS(SCSS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
var sass = require('gulp-sass'); | |
// browser-sync task for starting the server. | |
gulp.task('browser-sync', function() { | |
//watch files | |
var files = [ | |
'./*.css', | |
'./*.php' | |
]; | |
//initialize browsersync | |
browserSync.init(files, { | |
//browsersync with a php server | |
proxy: "http://yourlocalhost.dev/", | |
notify: false | |
}); | |
}); | |
// Sass task, will run when any SCSS files change & BrowserSync | |
// will auto-update browsers | |
gulp.task('sass', function () { | |
// style.css | |
gulp.src('./assets/scss/style.scss') | |
.pipe(sass()) | |
.pipe(gulp.dest('./')) | |
.pipe(reload({stream:true})); | |
// css/responsive.css | |
gulp.src('./assets/scss/responsive.scss') | |
.pipe(sass()) | |
.pipe(gulp.dest('./assets/css/')) | |
.pipe(reload({stream:true})); | |
// css/admin.css | |
gulp.src('./assets/scss/admin.scss') | |
.pipe(sass()) | |
.pipe(gulp.dest('./assets/css/')) | |
.pipe(reload({stream:true})); | |
}); | |
// Default task to be run with `gulp` | |
gulp.task('default', ['sass', 'browser-sync'], function () { | |
gulp.watch("./assets/scss/*.scss", ['sass']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you use it for static .html files, replace the browserSync with this one:
browserSync.init({ server: { baseDir: './' } });