Skip to content

Blade path empty during optimize with spatie/laravel-csp #123

@jamesj2

Description

@jamesj2

Volt Version

1.6.5

Laravel Version

11.27.2

PHP Version

8.3.13

Database Driver & Version

No response

Description

I'm unable to successfully run php artisan optimize with this spatie/laravel-csp and livewire/volt installed. Somehow it's causing the blade path to be empty in volt. Without optimize everything works, but I'm unable to optimize for deployment. I've filed an issue with spatie/laravel-csp. And they suggested I reach out to the Volt maintainers.

Steps To Reproduce

I used this tutorial to start a Laravel 11 project with volt/folio. Added a volt component and the spatie/laravel-csp package. Then run php optimize.

  config ............................................................................................................................. 619.69ms DONE
  events ............................................................................................................................... 2.03ms DONE
  routes ............................................................................................................................. 618.34ms DONE
  views ............................................................................................................................... 25.21ms FAIL

   TypeError 

  Livewire\Volt\FragmentAlias::encode(): Argument #2 ($path) must be of type string, null given, called in /Users/james/Herd/volt/vendor/livewire/volt/src/Precompilers/ExtractFragments.php on line 98

  at vendor/livewire/volt/src/FragmentAlias.php:15
     11▕ 
     12▕     /**
     13▕      * Encode the given fragment's component name and path into a base64 embedded alias.
     14▕      */
  ➜  15▕     public static function encode(string $componentName, string $path, ?string $basePath = null): string
     16▕     {
     17▕         $basePath = $basePath ?? static::$basePath ?? base_path();
     18▕ 
     19▕         return 'volt-anonymous-fragment-'.base64_encode(json_encode([

      +2 vendor frames 

  3   [internal]:0
      Livewire\Volt\Precompilers\ExtractFragments::Livewire\Volt\Precompilers\{closure}()
      +5 vendor frames 

  9   [internal]:0
      Illuminate\Foundation\Console\ViewCacheCommand::Illuminate\Foundation\Console\{closure}(Object(Symfony\Component\Finder\SplFileInfo), "/Users/james/Herd/volt/resources/views/pages/todos.blade.php")
    "require": {
        "php": "^8.2",
        "laravel/folio": "^1.1",
        "laravel/framework": "^11.9",
        "laravel/tinker": "^2.9",
        "livewire/livewire": "^3.5",
        "livewire/volt": "^1.6",
        "spatie/laravel-csp": "^2.10.1"
    },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions