symfony/asset-mapper
Symfony AssetMapper exposes asset directories, copies them to a public folder with digested/versioned filenames, and can generate an importmap so you can use modern JavaScript modules without a build step.
Pros:
?v=1.2) without requiring custom logic.public_path(), resource_path()), reducing friction.Cons:
asset-map:watch provides basic file-watching).public_path(), resource_path()) and Blade templating.asset-map:dump, asset-map:watch) fit Laravel’s workflow.AssetMapper as a singleton).?v=1.2) or ES module support (importmap)?asset-map:dump and asset-map:watch integrate seamlessly with Laravel’s CLI ecosystem.config/ directory (e.g., config/asset_mapper.php).AssetMapper component, which is already used in Laravel via symfony/http-foundation.AssetMapperBundle (if available for Laravel).<script type="module"> usage.| Phase | Action | Tools/Commands | Risks/Mitigations |
|---|---|---|---|
| Assessment | Audit existing asset pipeline (Mix/Vite, manual versioning). | composer why symfony/asset-mapper |
Identify conflicts early. |
| Pilot | Replace manual versioning (?v=1.2) with AssetMapper hashing. |
php artisan asset-map:dump |
Test cache-busting in staging. |
| ES Module Adoption | Add importmap for ES modules (e.g., React/Alpine). | Configure import_map in config. |
Validate CSP compatibility. |
| Hybrid Integration | Use AssetMapper for static assets, keep Mix/Vite for bundling. | Custom Blade helpers. | Ensure no duplicate asset processing. |
| Full Migration | Replace Mix/Vite entirely with AssetMapper (if no bundling needed). | Update package.json, remove Mix. |
Performance test asset dump times. |
config/asset_mapper.php with minimal settings (source/public dirs, versioning).return [
'source_dirs' => [resource_path('assets')],
'public_dir' => public_path('build'),
'version_strategy' => 'hash',
];
php artisan asset-map:dump and verify versioned assets in public/build.import_map in config and generate importmap.json.<script type="module"> imports in the browser.asset-map:dump to deployment scripts.asset_mapper.php) manages all assets.How can I help you explore Laravel packages today?