Merge pull request #1 from austinpray/guix77-8.0.0

Switches from livereload to browsersync
This commit is contained in:
guix77
2015-01-28 18:21:03 +01:00
3 changed files with 20 additions and 28 deletions

View File

@@ -24,5 +24,8 @@
"modernizr.js": { "modernizr.js": {
"bower": ["modernizr"] "bower": ["modernizr"]
} }
},
"config": {
"devUrl": "example.dev"
} }
} }

View File

@@ -1,12 +1,12 @@
// ## Globals // ## Globals
/*global $:true*/ /*global $:true*/
var $ = require('gulp-load-plugins')(); var $ = require('gulp-load-plugins')();
var _ = require('lodash'); var _ = require('lodash');
var argv = require('yargs').argv; var argv = require('yargs').argv;
var browserSync = require('browser-sync'); var browserSync = require('browser-sync');
var gulp = require('gulp'); var gulp = require('gulp');
var lazypipe = require('lazypipe'); var lazypipe = require('lazypipe');
var merge = require('merge-stream'); var merge = require('merge-stream');
// See https://github.com/austinpray/asset-builder // See https://github.com/austinpray/asset-builder
var manifest = require('asset-builder')('./assets/manifest.json'); var manifest = require('asset-builder')('./assets/manifest.json');
@@ -16,6 +16,9 @@ var manifest = require('asset-builder')('./assets/manifest.json');
// - `path.dist` - Path to the build directory. default: `dist/` // - `path.dist` - Path to the build directory. default: `dist/`
var path = manifest.paths; var path = manifest.paths;
// `config` - Store arbitrary configuration values here.
var config = manifest.config || {};
// `globs` - These ultimately end up in their respective `gulp.src`. // `globs` - These ultimately end up in their respective `gulp.src`.
// - `globs.js` - array of asset-builder js Depenency objects. Example: // - `globs.js` - array of asset-builder js Depenency objects. Example:
// ``` // ```
@@ -120,7 +123,7 @@ var jsTasks = function(filename) {
var writeToManifest = function(directory) { var writeToManifest = function(directory) {
return lazypipe() return lazypipe()
.pipe(gulp.dest, path.dist + directory) .pipe(gulp.dest, path.dist + directory)
.pipe($.livereload) .pipe(browserSync.reload, {stream:true})
.pipe($.rev.manifest, revManifest, { .pipe($.rev.manifest, revManifest, {
base: path.dist, base: path.dist,
merge: true merge: true
@@ -128,13 +131,6 @@ var writeToManifest = function(directory) {
.pipe(gulp.dest, path.dist)(); .pipe(gulp.dest, path.dist)();
}; };
// Start the server
gulp.task('browser-sync', function() {
browserSync({
proxy: "localhost"
});
});
// ## Gulp Tasks // ## Gulp Tasks
// Run `gulp -T` for a task summary // Run `gulp -T` for a task summary
@@ -147,8 +143,7 @@ gulp.task('styles', function() {
.pipe(cssTasks(dep.name))); .pipe(cssTasks(dep.name)));
}); });
return merged return merged
.pipe(writeToManifest('styles')) .pipe(writeToManifest('styles'));
.pipe(browserSync.reload({stream:true}));
}); });
// ### Scripts // ### Scripts
@@ -203,11 +198,14 @@ gulp.task('clean', require('del').bind(null, [path.dist]));
// ### Watch // ### Watch
// `gulp watch` - recompile assets whenever they change // `gulp watch` - recompile assets whenever they change
gulp.task('watch', ['browser-sync'], function() { gulp.task('watch', function() {
browserSync({
proxy: config.devUrl
});
gulp.watch([path.source + 'styles/**/*'], ['styles']); gulp.watch([path.source + 'styles/**/*'], ['styles']);
gulp.watch([path.source + 'scripts/**/*'], ['jshint', 'scripts', browserSync.reload]); gulp.watch([path.source + 'scripts/**/*'], ['jshint', 'scripts']);
gulp.watch(['bower.json'], ['wiredep']); gulp.watch(['bower.json'], ['wiredep']);
gulp.watch('**/*.php', function () { gulp.watch('**/*.php', function() {
browserSync.reload(); browserSync.reload();
}); });
}); });

View File

@@ -54,15 +54,6 @@ function assets() {
add_filter('script_loader_src', __NAMESPACE__ . '\\jquery_local_fallback', 10, 2); add_filter('script_loader_src', __NAMESPACE__ . '\\jquery_local_fallback', 10, 2);
} }
/**
* Livereload client
* https://github.com/livereload/livereload-js
*/
if (WP_ENV === 'development') {
wp_register_script('livereload', 'http://localhost:35729/livereload.js?snipver=1', null, false, true);
wp_enqueue_script('livereload');
}
if (is_single() && comments_open() && get_option('thread_comments')) { if (is_single() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply'); wp_enqueue_script('comment-reply');
} }