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

View File

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