Skip to content

Commit

Permalink
feat: add option to trigger "npm run build" on changed file
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Feb 2, 2024
1 parent a673f3b commit 85079f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
19 changes: 16 additions & 3 deletions LiveReload.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,18 @@ public function watch()
header("Cache-Control: no-cache");
header("Content-Type: text/event-stream");
$start = time();
$build = $this->wire->config->livereloadBuild;
$debug = $this->wire->config->debug;
while (true) {
$this->sse($file = $this->findModifiedFile($start));
$file = $this->findModifiedFile($start);

// if file changed and feature enabled run build script
if ($file && $debug && $build) exec("npm run build");

// send trigger to frontend
$this->sse($file);

// add note to log
if ($file) {
ob_end_flush();
$this->wire->log->prune('livereload', 1);
Expand All @@ -193,8 +203,11 @@ public function watch()
}
while (ob_get_level() > 0) ob_end_flush();
if (connection_aborted()) break;
$sleepSeconds = (float)$this->wire->config->livereload ?: 1;
sleep($sleepSeconds);

// sleep until next try
$sleepSeconds = (float)$this->wire->config->livereload ?: 1.0;
$sleepSeconds = 0.2;
usleep($sleepSeconds * 1000000);
}
}

Expand Down
10 changes: 5 additions & 5 deletions RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2738,11 +2738,11 @@ private function manifestConfig(InputfieldWrapper $fs)
]);
if ($this->m_background_color) $create = true;

$wrapper->add([
'type' => 'markup',
'label' => 'Icon',
'value' => 'TBD',
]);
// $wrapper->add([
// 'type' => 'markup',
// 'label' => 'Icon',
// 'value' => 'TBD',
// ]);

if ($create) {
$this->manifest()
Expand Down

0 comments on commit 85079f0

Please sign in to comment.