mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
dev: add live-reload development server
This commit is contained in:
@@ -11,9 +11,16 @@
|
||||
<link rel="stylesheet" href="assets/modern-normalize.css">
|
||||
<link rel="stylesheet" href="assets/common.css">
|
||||
<link rel="stylesheet" href="assets/main.css">
|
||||
<?php if (getenv('PHP_ENV') === 'development' || php_sapi_name() === 'cli-server'): ?>
|
||||
<?php if (php_sapi_name() === 'cli-server'): ?>
|
||||
<!-- Live reload for development -->
|
||||
<script src="/vendor/php-live-reload/php-live-reload/live-reload.js"></script>
|
||||
<script>
|
||||
(function poll() {
|
||||
fetch('/live-reload.php')
|
||||
.then(r => r.json())
|
||||
.then(d => { if (d.changed) location.reload(); else setTimeout(poll, 1000); })
|
||||
.catch(() => setTimeout(poll, 2000));
|
||||
})();
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
</head>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user