Fixes livereload

If the environment is development -> try loading the livereload client
being served by `gulp watch`
This commit is contained in:
Austin Pray
2015-01-24 13:17:11 -06:00
parent c95261e8a8
commit d5d2d02459
2 changed files with 13 additions and 10 deletions

View File

@@ -118,13 +118,11 @@ 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(require('gulp-debug'))
.pipe($.livereload) .pipe($.livereload)
.pipe($.rev.manifest, revManifest, { .pipe($.rev.manifest, revManifest, {
base: path.dist, base: path.dist,
merge: true merge: true
}) })
.pipe(require('gulp-debug'))
.pipe(gulp.dest, path.dist)(); .pipe(gulp.dest, path.dist)();
}; };

View File

@@ -19,10 +19,8 @@ namespace Roots\Sage\Assets;
*/ */
function asset_path($filename) { function asset_path($filename) {
$dist_path = get_template_directory_uri() . '/dist/'; $dist_path = get_template_directory_uri() . '/dist/';
$directory = dirname($filename) . '/';
if (WP_ENV === 'development') { $file = basename($filename);
return $dist_path . $filename;
}
$manifest_path = get_template_directory() . '/dist/assets.json'; $manifest_path = get_template_directory() . '/dist/assets.json';
@@ -32,10 +30,7 @@ function asset_path($filename) {
$manifest = []; $manifest = [];
} }
$directory = dirname($filename) . '/'; if (WP_ENV !== 'development' && array_key_exists($file, $manifest)) {
$file = basename($filename);
if (array_key_exists($file, $manifest)) {
return $dist_path . $directory . $manifest[$file]; return $dist_path . $directory . $manifest[$file];
} else { } else {
return $dist_path . $directory . $file; return $dist_path . $directory . $file;
@@ -59,6 +54,15 @@ 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');
} }
@@ -115,3 +119,4 @@ function google_analytics() {
if (GOOGLE_ANALYTICS_ID) { if (GOOGLE_ANALYTICS_ID) {
add_action('wp_footer', __NAMESPACE__ . '\\google_analytics', 20); add_action('wp_footer', __NAMESPACE__ . '\\google_analytics', 20);
} }