Skip to content

Commit

Permalink
feat: tweak livereload and add latte bar to tracy
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jan 9, 2023
1 parent 5c2436e commit 907add4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions LiveReload.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct()
'.*/\.vscode',
'.*/site/modules/TracyDebugger/tracy-.*',
'.*/site/templates/bundle/*',
'.*/site/assets/RockFrontend/.*.css',
'.*/site/assets/RockPdfDumps/*',
'.*/site/modules/RockBlocks/blocks/.*.css',
],
Expand Down
6 changes: 5 additions & 1 deletion RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ProcessWire;

use Latte\Bridges\Tracy\LattePanel;
use Latte\Engine;
use Latte\Runtime\Html;
use RockFrontend\LiveReload;
Expand Down Expand Up @@ -105,7 +106,7 @@ public static function getModuleInfo()
{
return [
'title' => 'RockFrontend',
'version' => '2.11.0',
'version' => '2.12.0',
'summary' => 'Module for easy frontend development',
'autoload' => true,
'singular' => true,
Expand Down Expand Up @@ -1440,6 +1441,9 @@ protected function renderFileLatte($file, $vars)
try {
require_once $this->path . "vendor/autoload.php";
$latte = new Engine();
if ($this->modules->isInstalled("TracyDebugger")) {
LattePanel::initialize($latte);
}
$latte->setTempDirectory($this->wire->config->paths->cache . "Latte");
$this->latte = $latte;
} catch (\Throwable $th) {
Expand Down
10 changes: 9 additions & 1 deletion livereload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ setTimeout(() => {
if (isModal) return;
let reloading = false;

// timeout after file change was detected
// you can set this to 5000 if you see multiple redirects
// that means that something triggers another reload on reload
// monitor the devtools console - it will show the detected file change
let redirecttimeout = 0;

let evtSource;
let startStream = function () {
let rf = RockFrontend;
Expand Down Expand Up @@ -39,7 +45,9 @@ setTimeout(() => {
// all fine, reload page
console.log("detected change - reloading");
reloading = true;
document.location.reload(true);
setTimeout(() => {
document.location.reload(true);
}, redirecttimeout);
}
};
};
Expand Down
4 changes: 2 additions & 2 deletions livereload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 907add4

Please sign in to comment.