Skip to content

Commit 4a7dbaf

Browse files
paulschwarztomschlick
authored andcommitted
Make auto linking from support Mix and Elixir manifests via config (#13)
* Make auto linking from support Mix and Elixir manifests via config * styleci alignment * styleci
1 parent 3f7c860 commit 4a7dbaf

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

config/server-push.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
],
1818
],
1919

20-
// Auto link all files that are built with elixir
21-
'autolink_elixir' => true,
20+
// Auto link all files from your built manifest
21+
'autolink_from_manifest' => true,
22+
23+
// Elixir example
24+
'manifest_path' => public_path('build/rev-manifest.json'),
25+
'assets_base_uri' => '/build/',
26+
27+
// Mix example
28+
//'manifest_path' => public_path('mix-manifest.json'),
29+
//'assets_base_uri' => '/',
2230
];

src/ServiceProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ protected function registerElixirLinks()
7878
{
7979
$instance = app('server-push');
8080

81-
if (config('server-push.autolink_elixir')) {
82-
$revPath = public_path().'/build/rev-manifest.json';
81+
if (config('server-push.autolink_from_manifest')) {
82+
$revPath = config('server-push.manifest_path');
83+
$assetsBaseUri = config('server-push.assets_base_uri');
8384
if (file_exists($revPath)) {
8485
$revMap = json_decode(file_get_contents($revPath), true);
8586
if ($revMap) {
8687
foreach (array_values($revMap) as $path) {
87-
$instance->queueResource('/build/'.ltrim($path, '/'));
88+
$assetUri = rtrim($assetsBaseUri, '/').'/'.ltrim($path, '/');
89+
$instance->queueResource($assetUri);
8890
}
8991
}
9092
}

0 commit comments

Comments
 (0)