nette/assets
Nette Assets is a lightweight asset pipeline for Nette apps. It helps you manage and reference CSS/JS, handle versioning/cache busting, and organize assets for development and production builds with a simple API and configuration.
Laravel Compatibility:
AssetManager singleton, IStorage interface) requires custom Laravel integration. Key strengths include:
?v=1.23) resolves Laravel’s stale asset issues in production.crossorigin attributes improve LCP (Core Web Vitals).IStorage, but Laravel-specific adapters (e.g., Flysystem) may need extension.mix-manifest.json or Vite’s asset hashing.asset() helper compatibility; requires custom Blade directives or service methods.Modularity:
AssetService) for dynamic asset generation.@asset('main.css')) for cleaner templates.<link href="/css/main.css"> → @asset('main.css')).development).ViteMapper (v1.0.4+) to proxy requests (e.g., http://localhost:5173).public/build/) as asset directories.mix() helper or Vite’s @vite() directive.nette/assets and Vite.IStorage implementations would be required.| Risk | Severity | Mitigation |
|---|---|---|
| Path Resolution Errors | High | Validate asset directories during boot; use absolute paths (e.g., public_path('css')). |
| Versioning Conflicts | Medium | Disable versioning in AppServiceProvider for development; use file-based hashing for edge cases. |
| Font Loading Issues | High | Enforce crossorigin for external fonts; test with Chrome DevTools’ Font Audit. |
| Vite/Mix Integration | Medium | Use ViteMapper for dev proxying; ensure build outputs are registered as asset directories. |
| Caching Invalidation | Low | Leverage Laravel’s cache tags or php artisan cache:clear for asset changes. |
| Dependency Conflicts | Low | Package uses PSR-4 autoloading; no known conflicts with Laravel core. |
| Long-Term Maintenance | Medium | Monitor Nette’s roadmap; consider forking for Laravel-specific enhancements (e.g., AssetService facade). |
Asset Strategy:
Build Tool Synergy:
nette/assets handle versioned paths for compiled assets?nette/assets (e.g., via mix-manifest.json parsing)?Versioning Approach:
?v=1.0) or file-based (e.g., ?v=md5-hash)? How will this interact with Laravel’s cache (e.g., config('app.version'))?Font and Security:
crossorigin vs. anonymous).@asset('script.js')->withNonce())?Performance Trade-offs:
Accept-Encoding middleware)?Team Adoption:
Scaling Considerations:
AwsS3Storage) may be needed.@asset() directives (e.g., @asset('css/main.css')).AssetManager as a singleton or resolve via AssetService facade.IStorage for Laravel-specific backends (e.g., Flysystem, S3).ViteMapper to proxy requests to Vite’s dev server.public/build/) as asset sources.@asset() directives.AssetManager in AppServiceProvider.ViteMapper for dev proxying.crossorigin).Blade::directive('asset', fn($expr) => "<?= app('assets')->asset($expr)?>")).@vite()) requires manual bridging.IStorage for unsupported backends (e.g., DigitalOceanSpaces).@asset() directives.AssetManager for versioning and caching.crossorigin for fonts.ViteMapper for dev proxying.How can I help you explore Laravel packages today?