Skip to content

Commit

Permalink
Make auto linking from support Mix and Elixir manifests via config (#13)
Browse files Browse the repository at this point in the history
* Make auto linking from support Mix and Elixir manifests via config

* styleci alignment

* styleci
  • Loading branch information
paulschwarz authored and tomschlick committed Feb 8, 2017
1 parent 3f7c860 commit 4a7dbaf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 10 additions & 2 deletions config/server-push.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
],
],

// Auto link all files that are built with elixir
'autolink_elixir' => true,
// Auto link all files from your built manifest
'autolink_from_manifest' => true,

// Elixir example
'manifest_path' => public_path('build/rev-manifest.json'),
'assets_base_uri' => '/build/',

// Mix example
//'manifest_path' => public_path('mix-manifest.json'),
//'assets_base_uri' => '/',
];
8 changes: 5 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ protected function registerElixirLinks()
{
$instance = app('server-push');

if (config('server-push.autolink_elixir')) {
$revPath = public_path().'/build/rev-manifest.json';
if (config('server-push.autolink_from_manifest')) {
$revPath = config('server-push.manifest_path');
$assetsBaseUri = config('server-push.assets_base_uri');
if (file_exists($revPath)) {
$revMap = json_decode(file_get_contents($revPath), true);
if ($revMap) {
foreach (array_values($revMap) as $path) {
$instance->queueResource('/build/'.ltrim($path, '/'));
$assetUri = rtrim($assetsBaseUri, '/').'/'.ltrim($path, '/');
$instance->queueResource($assetUri);
}
}
}
Expand Down

0 comments on commit 4a7dbaf

Please sign in to comment.