From 37357305690e4152430a428b6e0499c06f419d0b Mon Sep 17 00:00:00 2001 From: guix Date: Wed, 28 Jan 2015 07:40:49 +0100 Subject: [PATCH 1/3] browserSync --- gulpfile.js | 20 ++++++++++++++------ package.json | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b701c98..3d5b89c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ var $ = require('gulp-load-plugins')(); var _ = require('lodash'); var argv = require('yargs').argv; +var browserSync = require('browser-sync'); var gulp = require('gulp'); var lazypipe = require('lazypipe'); var merge = require('merge-stream'); @@ -127,6 +128,13 @@ var writeToManifest = function(directory) { .pipe(gulp.dest, path.dist)(); }; +// Start the server +gulp.task('browser-sync', function() { + browserSync({ + proxy: "aubonsite" + }); +}); + // ## Gulp Tasks // Run `gulp -T` for a task summary @@ -139,7 +147,8 @@ gulp.task('styles', function() { .pipe(cssTasks(dep.name))); }); return merged - .pipe(writeToManifest('styles')); + .pipe(writeToManifest('styles')) + .pipe(browserSync.reload({stream:true})); }); // ### Scripts @@ -194,13 +203,12 @@ gulp.task('clean', require('del').bind(null, [path.dist])); // ### Watch // `gulp watch` - recompile assets whenever they change -gulp.task('watch', function() { - $.livereload.listen(); +gulp.task('watch', ['browser-sync'], function() { gulp.watch([path.source + 'styles/**/*'], ['styles']); - gulp.watch([path.source + 'scripts/**/*'], ['jshint', 'scripts']); + gulp.watch([path.source + 'scripts/**/*'], ['jshint', 'scripts', browserSync.reload]); gulp.watch(['bower.json'], ['wiredep']); - gulp.watch('**/*.php').on('change', function(file) { - $.livereload.changed(file.path); + gulp.watch('**/*.php', function () { + browserSync.reload(); }); }); diff --git a/package.json b/package.json index 6716046..1d72c38 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ }, "devDependencies": { "asset-builder": "~0.3.0", + "browser-sync": "^1.9.1", "del": "^1.1.1", "gulp": "^3.8.10", "gulp-changed": "^1.1.0", @@ -36,7 +37,6 @@ "gulp-imagemin": "^2.0.0", "gulp-jshint": "^1.8.4", "gulp-less": "^2.0.1", - "gulp-livereload": "^3.4.0", "gulp-load-plugins": "^0.8.0", "gulp-pleeease": "^1.1.0", "gulp-plumber": "^0.6.3", From cf4f58d5ccea77f0dae8656e9a7250f32d86fa30 Mon Sep 17 00:00:00 2001 From: guix Date: Wed, 28 Jan 2015 07:49:40 +0100 Subject: [PATCH 2/3] localhost proxy by default --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 3d5b89c..5f61a89 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -131,7 +131,7 @@ var writeToManifest = function(directory) { // Start the server gulp.task('browser-sync', function() { browserSync({ - proxy: "aubonsite" + proxy: "localhost" }); }); From c85d0592397f787e106cf81c9b2aa75c4b778b69 Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Wed, 28 Jan 2015 09:22:05 -0600 Subject: [PATCH 3/3] Switches from livereload to browsersync Formatting Removes references to livereload Removes enqueued livereload client --- assets/manifest.json | 3 +++ gulpfile.js | 36 +++++++++++++++++------------------- lib/assets.php | 9 --------- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/assets/manifest.json b/assets/manifest.json index 5e7f254..e28cc48 100644 --- a/assets/manifest.json +++ b/assets/manifest.json @@ -24,5 +24,8 @@ "modernizr.js": { "bower": ["modernizr"] } + }, + "config": { + "devUrl": "example.dev" } } diff --git a/gulpfile.js b/gulpfile.js index 5f61a89..06df06b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,12 +1,12 @@ // ## Globals /*global $:true*/ -var $ = require('gulp-load-plugins')(); -var _ = require('lodash'); -var argv = require('yargs').argv; +var $ = require('gulp-load-plugins')(); +var _ = require('lodash'); +var argv = require('yargs').argv; var browserSync = require('browser-sync'); -var gulp = require('gulp'); -var lazypipe = require('lazypipe'); -var merge = require('merge-stream'); +var gulp = require('gulp'); +var lazypipe = require('lazypipe'); +var merge = require('merge-stream'); // See https://github.com/austinpray/asset-builder 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/` 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.js` - array of asset-builder js Depenency objects. Example: // ``` @@ -120,7 +123,7 @@ var jsTasks = function(filename) { var writeToManifest = function(directory) { return lazypipe() .pipe(gulp.dest, path.dist + directory) - .pipe($.livereload) + .pipe(browserSync.reload, {stream:true}) .pipe($.rev.manifest, revManifest, { base: path.dist, merge: true @@ -128,13 +131,6 @@ var writeToManifest = function(directory) { .pipe(gulp.dest, path.dist)(); }; -// Start the server -gulp.task('browser-sync', function() { - browserSync({ - proxy: "localhost" - }); -}); - // ## Gulp Tasks // Run `gulp -T` for a task summary @@ -147,8 +143,7 @@ gulp.task('styles', function() { .pipe(cssTasks(dep.name))); }); return merged - .pipe(writeToManifest('styles')) - .pipe(browserSync.reload({stream:true})); + .pipe(writeToManifest('styles')); }); // ### Scripts @@ -203,11 +198,14 @@ gulp.task('clean', require('del').bind(null, [path.dist])); // ### Watch // `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 + 'scripts/**/*'], ['jshint', 'scripts', browserSync.reload]); + gulp.watch([path.source + 'scripts/**/*'], ['jshint', 'scripts']); gulp.watch(['bower.json'], ['wiredep']); - gulp.watch('**/*.php', function () { + gulp.watch('**/*.php', function() { browserSync.reload(); }); }); diff --git a/lib/assets.php b/lib/assets.php index 60c50ef..d6fedb0 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -54,15 +54,6 @@ function assets() { 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')) { wp_enqueue_script('comment-reply'); }