Chrome has introduced a feature (currently still behind a feature-flag) to automatically discover workspace folders. What this enables is an edit-save-see-without-refreshing experience for resources like CSS files. This might be a good addition to the development server when this comes out from behind a flag.
use util\UUID;
use web\Application;
use web\handler\FilesFrom;
class Hello extends Application {
public function routes() {
$workspace= json_encode(['workspace' => [
'root' => (string)$this->environment->webroot(),
'uuid' => (string)UUID::randomUUID()
]]);
return [
'/(style.css|favicon.ico)' => new FilesFrom($this->environment->webroot()),
'/.well-known/appspecific/com.chrome.devtools.json' => function($req, $res) use($workspace) {
$res->answer(200);
$res->send($workspace, 'application/json; charset=utf-8');
},
'/' => function($req, $res) {
$res->answer(200);
$html= sprintf(<<<'HTML'
<html lang="en">
<head>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<h1>Hello %s</h1>
</body>
</html>
HTML,
htmlspecialchars($req->param('name', 'Guest'))
);
$res->send($html, 'text/html; charset=utf-8');
},
];
}
}
Chrome has introduced a feature (currently still behind a feature-flag) to automatically discover workspace folders. What this enables is an edit-save-see-without-refreshing experience for resources like CSS files. This might be a good addition to the development server when this comes out from behind a flag.
How it works
/.well-known/appspecific/com.chrome.devtools.jsonand specify the workspace's root directory in itThe com.chrome.devtools.json file
{ "workspace" : { "root" : "/path/to/web/root", "uuid" : "6e29a6df-42e1-4f39-9a1b-6af7546a8ebf" } }Discovery and consent
Editing experience
Proof of concept
See also: