Laravel Assets are the CSS, JavaScript, and image files powering every modern Laravel interface, and in 2026 they sit at the intersection of native ES modules, serverless delivery, and AI-assisted testing pipelines. If you are shipping a Laravel application today, your asset workflow directly determines your Core Web Vitals, your CDN bill, and your team's daily friction. This guide walks you through every layer of that workflow, from Vite configuration to Bref-powered CloudFront delivery, with persona-matched recommendations at the end.
What Are Laravel Assets and Why They Matter in 2026
Laravel Assets include any static or compiled file that the browser loads alongside your HTML: stylesheets, JavaScript bundles, fonts, SVG icons, and image sprites. Laravel keeps the source files inside resources/ and compiles them into public/build through a bundler, then references the output via the asset() helper inside Blade.
Definition: Laravel Assets are source files stored inresources/that get compiled, versioned, and exposed through thepublic/directory, then referenced in templates using helpers likeasset()ormix()for automatic cache-busting.
The reason this matters more in 2026 than it did in 2023 is scope. Modern Laravel stacks pair server-rendered Blade with reactive layers from Inertia and Livewire, and the line between "back-end HTML" and "front-end JavaScript" has effectively dissolved. Every team is now a full-stack team, and the asset pipeline is the contract that holds the two sides together. Break that contract and you get 404s in production, stale hashes in the browser, and a CDN that serves yesterday's CSS.
Three forces have raised the stakes. First, the framework now ships Vite as the default bundler. Second, serverless deployments via Bref and AWS SAM are mainstream, so compiled assets often live in a CloudFront distribution rather than on the same host as PHP. Third, AI coding agents and Pest's new TIA engine have made front-end changes part of the automated test loop, so a broken Vite manifest now breaks your CI.
Current Trends Shaping Laravel Asset Management
Three shifts are defining how Laravel teams build and ship assets this year.
Vite as Default Bundler
Since Laravel 10, Vite has replaced Laravel Mix as the recommended tool. Vite serves source files over native ES modules during development, which removes the bundling step from the inner loop and gives you sub-second hot-module replacement. The trade-off is that production builds still emit a single hashed bundle, so you get the developer experience of unbundled code with the network efficiency of a bundle.
ESM Adoption
ECMAScript modules are no longer experimental in 2026. Every mainstream front-end library ships ESM-first, and Vite's dependency pre-bundling handles the messy CJS packages automatically. The result is simpler vite.config.js files, fewer polyfills, and a smaller payload reaching users.
Serverless Front-Ends
Deploying Laravel to AWS Lambda with Bref and the AWS Serverless Application Model (SAM) has moved from clever demo to production pattern. Compiled assets are pushed to S3 and fronted by Amazon CloudFront, which the SAM template provisions automatically.
Tools & Environment Needed for Modern Asset Workflows
Before you touch a config file, lock in a compatible stack. In 2026 that means PHP 8.4, Laravel 10 or later, and Node 20 LTS or Node 22.
- Laravel 10+ & PHP 8.4: Required for native property hooks, asymmetric visibility, and the array helper improvements that Vite plugins rely on. Pest v5 also requires PHP 8.4 as its baseline.
- Node.js & npm/yarn: Vite runs on Node 20 LTS or newer. Use pnpm if your monorepo spans multiple packages; the lockfile is tighter and CI caches are smaller.
- Vite & Livewire Integration: Livewire 3 ships with a first-party Vite plugin that resolves Alpine and Wire directives automatically. Install it with
npm install --save-dev @livewire/viteand add it to the plugins array invite.config.js. - Inertia adapter:
@inertiajs/inertiaplus the Laravel adapter. Inertia uses Vite's module graph to know which page components need to be hydrated, which becomes important for testing later.
For testing, install Pest v5 and the new plugin suite: Agent, Evals, PHPStan, and Rector. The TIA engine watches PHP, migrations, JS, Blade, and asset files, so a CSS-only change no longer forces a full test run. More on that in the dynamic loading section.
Step-by-Step Vite Configuration for Laravel Assets
Start with a fresh project and wire Vite end-to-end.
Installing Vite
Scaffold Laravel through Composer, then install the front-end dependencies:
composer create-project --prefer-dist laravel/laravel blog
cd blog
npm install
npm run dev
The dev server boots on http://localhost:5173 and watches every file under resources/. Leave it running in one terminal while you edit Blade and JS in another.
Configuring vite.config.js
The default config covers most apps, but production builds need explicit input entries and a clean output directory. Add the Livewire plugin if you are using Livewire, and configure path aliases for your resources/js folders.
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import livewire from '@livewire/vite';
export default defineConfig({
plugins: [
livewire({}),
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
build: {
manifest: true,
rollupOptions: {
output: { entryFileNames: 'assets/[name].[hash].js' },
},
},
});
Integrating with Blade & Inertia
In Blade, load the directive stack with @vite(['resources/css/app.css', 'resources/js/app.js']). The directive reads the manifest, appends the content hash, and resolves to a CDN URL when CDN_URL is set. Inertia pages are imported into resources/js/app.js and rendered with the <inertia> Blade component, so the bundler knows which chunks to lazy-load.
Dynamic Loading with Inertia, Livewire & WebSockets
Static asset pipelines belong to 2022. In 2026 the bundler, the reactive layer, and the transport layer cooperate to load code only when it is needed.
On-Demand Component Scripts
Livewire 3 ships each component as a lazy ES module. When a Blade component renders for the first time, Livewire fetches its compiled script from the manifest. Vite's dynamic import() calls keep the initial payload small, and code-split routes automatically.
Streaming Assets via WebSockets
For real-time features, Aerys remains a viable async PHP server that supports HTTP and WebSocket on the same port. Run it with vendor/bin/aerys -d -c config.php and connect your JavaScript client through a thin WebSocket layer. Game-style Laravel builds (as covered in the SitePoint Laravel and WebSocket guide) often use Aerys to push binary asset chunks, sprite updates, and audio streams without polling.
Hot-Module Replacement in 2026
Vite's HMR works out of the box for plain JavaScript. For Livewire and Inertia, enable refresh: true in the Laravel plugin so the page reloads when PHP files change, while JavaScript still hot-swaps. The Agent plugin for Pest can verify that an HMR session stays green by asserting the page renders after a simulated file change, which is a useful guard for CI.
Serving Laravel Assets from AWS Lambda & CloudFront
Serverless Laravel deployments are no longer experimental. The reference architecture uses Bref, AWS SAM, and a CloudFront distribution fronting an S3 bucket that holds public/build.
Bref & SAM Setup
Install the bridge package and clone the AWS sample template, then deploy with the guided SAM command:
composer require bref/laravel-bridge
git clone https://github.com/aws-samples/php-examples-for-aws-lambda/
cd 0.4-Building-A-Serverless-Laravel-App-With-AWS-SAM
sam deploy -g
The full step list is documented in the AWS serverless LAMP stack guide. Two Lambda constraints matter for assets: the 512 MB temporary file system is transient, so never write uploads to local disk, and session state must live in cookies or a database, not in memory.
CDN Caching Strategies
Set the CDN_URL environment variable to your CloudFront domain. Laravel's asset() helper will then emit absolute URLs to the CDN, and hashed filenames give you long cache lifetimes without staleness. Configure the distribution to forward the Cache-Control and If-None-Match headers from the S3 origin.
Container-Based Asset Servers
For large media workloads, build a custom Lambda container image that bundles Nginx, your build output, and a tiny PHP-FPM sidecar. The image runs as a Lambda function behind CloudFront and handles media transcoding or image resizing on demand. Bref's FPM custom runtime layer can be layered on top of a public Docker image.
Best Practices for Fast Asset Delivery
Optimization is not a single switch. It is a stack of small decisions that compound.
Tree-Shaking & Code Splitting
Vite uses Rollup under the hood, so unused exports are removed automatically. Import only the helpers you need from large libraries, and let dynamic import() statements split heavy modules like chart engines or PDF generators into their own chunks.
Cache-Busting & Versioning
Run npm run build for production. Vite writes a manifest.json file that Laravel reads through the @vite directive, so every reference gets a content hash. Skip version() helper hacks; the manifest is the source of truth.
Minification & Compression
Enable Brotli compression on CloudFront or your reverse proxy. Vite minifies by default, but double-check with a build report. Aim for a 30 KB initial JavaScript budget; anything larger warrants a code-split.
When to Use Vite vs Mix vs Rollup
The right bundler depends on the team and the codebase, not the calendar.
| Bundler | Best For | Watch Out For |
|---|---|---|
| Vite | New projects, ES module libraries, Livewire/Inertia apps | Legacy IE polyfills need manual setup |
| Laravel Mix | Legacy projects already on Webpack 5 | No longer receives major updates, slower HMR |
| Rollup (direct) | Standalone JS packages and design systems | No Laravel integration; you wire the manifest yourself |
For a greenfield Laravel app, the answer is always Vite. The "Mix or Vite?" question usually means "should I migrate my old codebase?", and the answer is a gradual one: keep Mix for the legacy build, ship new features through Vite, and consolidate once the Mix surface area is gone.
Checklist for Production-Ready Laravel Assets
Run this list before every release. It catches the issues that turn into 3 a.m. pages.
Security Considerations
Restrict write access to the public/ directory and never expose storage/ directly. After the recent Laravel-Lang supply chain attack, inspect composer.lock for compromised package versions, audit outbound network traffic, and rotate any exposed application secrets. The attack payload used a .vbs script invoked through cscript on Windows and a hidden exec('php ...') call on Linux and macOS, which is why a clean rebuild from a known-good image is the only fully safe recovery path.
Testing with Pest & PHPStan
Wire Pest's TIA engine into the test runner so asset-only changes skip unrelated suites. Configure it in tests/Pest.php:
pest()->tia()->always()->locally()->baselined()->filtered();
Pair this with the PHPStan plugin so static analysis understands Pest matchers. The Evals plugin can score generated LLM documentation against the manifest, and the Agent plugin runs one-off snippets through a full Laravel test context for AI-driven refactors.
Automated CI/CD Pipelines
Cache node_modules and vendor/ between runs, run npm run build before tests, and upload public/build as a pipeline artifact. Push the artifact to S3 and invalidate the CloudFront distribution in a single step after tests pass.
Top Issues and Fixes
These three errors account for the majority of "why is my asset 404ing?" tickets.
Module Resolution Errors
Symptom: Failed to resolve import "./Component.vue" in the Vite log. Fix: confirm the file exists, check vite.config.js aliases, and run npm run build once to populate the manifest. If you see this in production only, your CI is likely shipping a stale build.
Hot-Reload Failures
Symptom: Vite reports the websocket is connected but the page does not update. Fix: disable browser extensions that intercept WebSockets, ensure the dev server binds to 0.0.0.0 in Docker, and check that the HMR port is exposed by your firewall.
Deployment Cache Invalidation
Symptom: New CSS is on the server but users still see the old version. Fix: invalidate the CloudFront paths (/build/*) after every deploy, or rely on content-hashed filenames and set Cache-Control: public, max-age=31536000, immutable for /build/assets/.
Persona-Based Asset Strategy
Match the workflow to the team. A solo developer, a mid-size team, and an enterprise platform have very different priorities.
| Target Persona | Recommended Option | Key Reason & Real-World Benefit |
|---|---|---|
| Solo Developer | Vite + Laravel Cloud + Pest v5 TIA | Zero-config bundler, instant HMR, and tests that skip when only assets change, so you ship features instead of babysitting CI. |
| Mid-Size Team | Vite + Bref + CloudFront + GitHub Actions | SAM provisions the CDN for you, hashed filenames give you year-long cache lifetimes, and CI artifacts make rollbacks a single revert. |
| Enterprise Architecture | Vite + Rollup design system + custom Lambda container + AWS SAM + Aerys WebSockets | Centralized component library, container-based asset server for media processing, and persistent real-time channels for transactional UIs. |
Verdict: For 90% of teams in 2026, the winning stack is Laravel 11, Vite, Bref on Lambda, and CloudFront in front of an S3 bucket. Add Pest v5 with TIA, and your test loop becomes fast enough to run on every commit.
People Also Ask About Laravel Assets
Can I use Laravel Mix with Vite?
Yes, but it adds weight. Mix and Vite both write to public/, so duplicate bundles are easy. Run Mix for legacy code and Vite for new code during migration, then remove Mix once the legacy surface is gone.
How to enable SSR with Inertia?
Install the Inertia SSR bundle with npm install @inertiajs/server, add the middleware to your HTTP kernel, and run the Node process alongside PHP. Inertia's Vite plugin emits a server entry that the Node process renders on the first request, then hands the hydrated page to the browser.
What are the benefits of serverless asset delivery?
Lower idle cost, automatic global caching through CloudFront, and zero server patching. The trade-off is the 512 MB ephemeral filesystem and the need to externalize session state, both of which are solved by storing sessions in cookies and uploads in S3.
Your 2026 Laravel Asset Playbook
Laravel Assets are the spine of every modern Laravel application, and the 2026 workflow pairs Vite's native ESM speed with Bref-powered CloudFront delivery and Pest v5's TIA-aware test loop.
Key Takeaways
- Vite is the default for a reason: instant HMR, native ESM, and a clean Rollup-based production build.
- Serverless Laravel via Bref and SAM is production-ready, provided you externalize session state and uploads.
- Pest v5 plus the Agent, PHPStan, Rector, and Evals plugins turns asset changes into a fully tested, AI-verified workflow.
- Supply-chain hygiene matters; audit your
composer.lockafter every dependency update.
Next Steps
- Spin up a fresh Laravel 11 project and run
npm installto confirm Vite is wired. - Add
CDN_URLto your.envand verify@viteemits absolute URLs. - Install Pest v5 and enable TIA in
tests/Pest.php; run the suite once to record the baseline. - If you are deploying serverless, clone the AWS SAM Laravel sample and run
sam deploy -gin a staging account. - Set up a CloudFront invalidation hook in your CI pipeline and ship your next feature with confidence.
That is the complete 2026 playbook. Configure once, trust the manifest, and spend your time on the product instead of on broken asset links.