Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Basset work on Vapor #58

Merged
merged 4 commits into from Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/BassetManager.php
Expand Up @@ -161,7 +161,7 @@ private function prepareAttributes(array $attributes = []): string
public function getPath(string $asset): string
{
return Str::of($this->basePath)
->append(str_replace([base_path(), 'http://', 'https://', '://', '<', '>', ':', '"', '|', "\0", '*', '`', ';', "'", '+'], '', $asset))
->append(str_replace([base_path().'/', base_path(), 'http://', 'https://', '://', '<', '>', ':', '"', '|', "\0", '*', '`', ';', "'", '+'], '', $asset))
->before('?')
->replace('/\\', '/');
}
Expand Down Expand Up @@ -274,7 +274,7 @@ public function basset(string $asset, bool|string $output = true, array $attribu
// Clean source map
$content = preg_replace('/sourceMappingURL=/', '', $content);

$result = $this->disk->put($path, $content);
$result = $this->disk->put($path, $content, 'public');

if ($result) {
$output && $this->echoFile($url, $attributes);
Expand Down Expand Up @@ -346,7 +346,7 @@ public function bassetBlock(string $asset, string $code, bool $output = true): S
$cleanCode = preg_replace('/^'.($matches[0] ?? '').'/m', '', $cleanCode);

// Store the file
$result = $this->disk->put($path, $cleanCode);
$result = $this->disk->put($path, $cleanCode, 'public');

// Delete old hashed files
$dir = Str::beforeLast($path, '/');
Expand Down Expand Up @@ -436,7 +436,7 @@ public function bassetArchive(string $asset, string $output): StatusEnum

// internalize all files in the folder
foreach (File::allFiles($tempDir) as $file) {
$this->disk->put("$path/{$file->getRelativePathName()}", File::get($file));
$this->disk->put("$path/{$file->getRelativePathName()}", File::get($file), 'public');
}

File::delete($tempDir);
Expand Down Expand Up @@ -486,7 +486,7 @@ public function bassetDirectory(string $asset, string $output): StatusEnum

// internalize all files in the folder
foreach (File::allFiles($asset) as $file) {
$this->disk->put("$path/{$file->getRelativePathName()}", File::get($file));
$this->disk->put("$path/{$file->getRelativePathName()}", File::get($file), 'public');
}

$this->cacheMap->addAsset($asset);
Expand Down
4 changes: 2 additions & 2 deletions src/config/backpack/basset.php
Expand Up @@ -5,11 +5,11 @@
'dev_mode' => env('BASSET_DEV_MODE', env('APP_ENV') === 'local'),

// disk and path where to store bassets
'disk' => 'public',
'disk' => env('BASSET_DISK', 'public'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document these new .ENV variables please. And ideally also create a section in the README called "How to use on Laravel Vapor"

'path' => 'basset',

// use cache map file (.basset)
'cache_map' => true,
'cache_map' => env('BASSET_CACHE_MAP', true),

// view paths that may use @basset
// used to internalize assets in advance with artisan basset:internalize
Expand Down