visuellverstehen/statamic-sourcestack
A Statamic addon by visuellverstehen that provides a Source Stack fieldtype for combining multiple content sources—such as entries, assets, and custom links—into one editable, orderable list. Use it to build flexible content blocks, curated feeds, and mixed-source navigations.
This is a small, focused Blade/asset-registration package: it lets any view, component, or partial register frontend files (JS/CSS) locally, then renders them all in one place in your layout — the alternative to hand-rolling @once + @push + @stack + @vite in every component.
Minimal path:
composer require the package (Laravel package discovery handles the service provider; there is nothing to register manually unless the readme says otherwise).@once + @stack — that comparison is the fastest way to decide whether the package fits your layout at all. If you already have a working @push/@stack pipeline and don't mind the duplication, you may not need it.</head>, JS entries before </body>.First real use case: a Blade component that ships its own JS/CSS (resources/js/charts.js, resources/css/charts.css) and registers those files next to its markup, so the layout doesn't need to know which components exist on the page.
Component-local registration. The core pattern is: markup and its assets live together. A <x-chart> component registers charts.js in its own template; the layout renders the aggregate. This keeps the layout free of conditional @vite([...]) arrays that grow with every new widget.
Single render point. Treat the render directive like @stack('scripts'): exactly one call per layout. If you have multiple layouts (app, auth, mail-preview), each needs its own call, and you should not nest them.
Multiple files at once. v1.0.1 lets you pass several sources in a single call, separated by | (deliberately aligned with the vite tag syntax so the two read the same way) or by comma. Because filenames are now whitespace-trimmed, 'resources/js/a.js | resources/js/b.js' is safe — you can format long asset lists across lines for readability.
Group related registrations. Rather than one call per file, register a feature's bundle in one call. It reduces duplication and makes ordering obvious in the source.
Livewire / Inertia interplay. Register from the server-rendered component, not from a JS hook. On Livewire navigations the layout is not re-rendered, so anything registered during a subsequent component render will not appear — register assets for navigated pages in the initial full page load, or guard with a persistent layout.
Conditional assets. Registering inside an @if block works naturally and is the main reason to prefer this over a static array in the layout. Keep the condition next to the markup that needs it, not in the layout.
Encapsulating third-party widgets. Wrap a JS library + its CSS in a single anonymous component that registers both and renders the mount point. Consumers then get dependency and styling in one tag.
| or , yourself and didn't trim, or if you're on v1.0.0, filenames with leading/trailing spaces silently failed to resolve. Upgrade: it's a patch release with no API change.| and , both work. Pick one per codebase and stick to it — mixed delimiters in one call is the kind of thing that looks fine until someone adds a filename containing a comma.@once + @stack was doing real work for you.b.js depends on a.js being loaded first, register them in the same call in the right sequence rather than relying on component render order, which can shift with layout changes.@once + @stack in general. Inline <script> blocks, JSON payloads, and non-file content still belong in a normal stack. The package handles file URLs; keep raw markup in @push.public/build/manifest.json and that npm run dev is running before debugging the directive.php artisan view:clear — directive changes are compiled into cached Blade views and stale caches are the usual cause of "the fix didn't apply."How can I help you explore Laravel packages today?