public static function watch($compilers) { self::$watching = true; if (isset($_GET['autobuild'])) { if (!$_GET['autobuild']) { header('content-type: text/javascript'); die(require __DIR__ . '/autobuild.js'); } else { self::runWatch($compilers, $_GET['autobuild']); die; } } }
<?php require_once __DIR__ . '/../vendor/autoload.php'; $scssBuilder = new AutoBuildScss(__DIR__ . '/scss/style.scss', __DIR__ . '/cache/style.css', glob(__DIR__ . '/scss/*.scss')); $reloader = new AutoBuildReloader(glob(__DIR__ . '/*.{php,js,html}', GLOB_BRACE)); $dev = in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']); if ($dev) { AutoBuild::watch([$scssBuilder, $reloader]); } else { $scssBuilder(); }
<?php require __DIR__ . '/autobuild.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>AutoBuild Test</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="cache/style.css"> </head> <body> <h1>AutoBuild.</h1> <?php echo AutoBuild::script(); ?> </body> </html>