diff --git a/gulpfile.js b/gulpfile.js index edd2ff9..7cc0e5c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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)(); }; diff --git a/lib/assets.php b/lib/assets.php index 6aa0c11..60c50ef 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -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); } +