Skip to content

Commit

Permalink
Merge branch 'main' of github.com:spatie/livewire-filepond
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jul 16, 2024
2 parents 75ca55f + c736c23 commit a01ea6e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/LivewireFilepondServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function packageBooted(): void
return Utils::pretendResponseIsFile(__DIR__.'/../resources/dist/filepond.js');
})->name('livewire-filepond.scripts');

Route::get('_filepond/styles', function () {
return Utils::pretendResponseIsFile(__DIR__.'/../resources/dist/filepond.css', 'text/css');
})->name('livewire-filepond.styles');

Blade::component('livewire-filepond::upload', 'filepond::upload');

Blade::directive('filepondScripts', function () {
Expand All @@ -33,11 +37,16 @@ public function packageBooted(): void
$scripts = [];

// Default to dynamic js (served by a Laravel route).
$fullAssetPath = route('livewire-filepond.scripts');
$fullScriptPath = route('livewire-filepond.scripts');
$fullStylePath = route('livewire-filepond.styles');

// Use static assets if they have been published
if (file_exists(public_path('vendor/livewire-filepond/filepond.js'))) {
$fullAssetPath = asset('/vendor/livewire-filepond/filepond.js');
$fullScriptPath = asset('/vendor/livewire-filepond/filepond.js');
}

if (file_exists(public_path('vendor/livewire-filepond/filepond.css'))) {
$fullStylePath = asset('/vendor/livewire-filepond/filepond.css');
}

if (is_file(__DIR__.'/../resources/hot')) {
Expand All @@ -47,7 +56,8 @@ public function packageBooted(): void
$scripts[] = sprintf('<script type="module" src="%s" defer data-navigate-track></script>', "{$url}/@vite/client");
} else {
$scripts[] = <<<HTML
<script type="module" src="{$fullAssetPath}?v={$version}" data-navigate-once defer data-navigate-track></script>
<link rel="stylesheet" type="text/css" href="{$fullStylePath}?v={$version}">
<script type="module" src="{$fullScriptPath}?v={$version}" data-navigate-once defer data-navigate-track></script>
HTML;
}

Expand Down

0 comments on commit a01ea6e

Please sign in to comment.