integrated/asset-bundle
Integrated Asset Bundle is a Laravel package for managing and serving front-end assets, bundling CSS and JavaScript into optimized files and simplifying asset registration, versioning, and publishing within PHP applications.
Before you type composer require. This package has 0 stars, 0 dependents, and no public issue corpus, so there is no "getting started" guide beyond the README. Your first 60–90 minutes are source-reading, not installation. Open these files in order:
composer.json — confirm the illuminate/* and php constraints actually include your Laravel version. Do not assume; the README's compatibility claim is not a contract.src/*ServiceProvider.php — find what it registers (Blade directives, singletons, console commands) and whether it writes to disk at boot.node/terser or uses a pure-PHP minifier. That single fact determines your CI and container requirements.Install pinned, not floating:
composer require integrated/asset-bundle --dev # start dev-only
# then pin to the resolved SHA in composer.json before it touches main
Publish the config (verify the tag name from the provider's publishes() call — it may be asset-bundle-config, config, or absent entirely):
php artisan vendor:publish --provider="Integrated\AssetBundle\AssetBundleServiceProvider"
First use case — the one worth validating: define a single app bundle containing your layout's CSS and JS, reference it from resources/views/layouts/app.blade.php with the package's directive, then run the same page under APP_ENV=local and APP_ENV=production with php artisan config:cache applied. If those two environments disagree about the asset URL, stop and reconsider — that is the exact failure mode this class of package produces in production, and you want to find it in an afternoon on a branch, not on deploy day.
The directive and helper names (@assetBundle, @bundle, asset_bundle() — whatever they are) must be read from the provider. Guessing wastes more time than reading.
Config-first bundling, one file per concern. The package's value is a single declarative map of bundle name → source files → output path. Keep that map honest: one bundle for the global layout, one per page or per feature area, and nothing that isn't referenced by a view. The expected shape is roughly:
// config/asset-bundle.php (verify keys against the published file)
'bundles' => [
'app' => ['js' => ['resources/js/app.js'], 'css' => ['resources/css/app.css']],
'admin' => ['js' => ['resources/js/admin.js'], 'css' => ['resources/css/admin.css']],
],
'output_path' => 'assets/build', // verify
'minify' => env('ASSET_MINIFY', true),
Build once in the pipeline (php artisan asset-bundle:build, or whatever the registered command is), commit nothing, and cache the output directory in CI between runs.
Environment-aware inclusion, not environment-aware config. Rather than branching in Blade (@if(app()->isProduction())), let the package decide. In local it should emit individual unminified files for readable stack traces; in production it emits the hashed bundle. Your layout template stays identical across environments — that is the whole point and the only thing keeping the two paths from drifting.
Stack-based composition for page-specific bundles. Push bundle names onto a Blade stack from child views and render the stack in the layout. This keeps per-page asset loading declarative and prevents the "which view includes which script" archaeology that hand-rolled <script> tags always produce:
{{-- layouts/app.blade.php --}}
@assetBundle('app')
@stack('assets')
{{-- pages/reports.blade.php --}}
@push('assets') @assetBundle('reports') @endpush
Treat it as a post-processor, not a replacement for your source build. The realistic integration for a modern Laravel app is: Vite (or Mix) compiles source → this package concatenates/minifies/hashes the already-built artifacts in public/. Two build steps, one direction of flow. Do not wire it to consume raw resources/ files if you're also running Vite — you will have two answers to "what is the URL for app.css" and they will diverge the first time someone adds a plugin.
Parallel-run behind a flag for evaluation. If you're spiking this against an incumbent, add an env flag that switches the layout between @vite(...) and the package's directive, both pointing at equivalent output. Compare: hashed filename stability across two consecutive builds, response headers, and the resulting bundle sizes. One sprint, then decide.
Deploy sequence that actually works:
composer install --no-dev
npm ci && npm run build # source compilation
php artisan asset-bundle:build # bundling/minify/hash
php artisan config:cache
php artisan route:cache
php artisan view:cache
Run this exact sequence in CI, not just php artisan test. Config-cache interaction is where service-provider-registered asset paths classically break, and a green test suite says nothing about it.
Write your own smoke test regardless. Two assertions, both cheap, both catching the expensive failures:
// 1. the URL your layout actually renders returns 200
// 2. two consecutive builds produce identical hashed filenames
The second one protects CDN cache hit rates and is trivially overlooked.
public/ are a blocker, not an inconvenience. If the package compiles on request rather than only via an artisan command, it will fail in a hardened, read-only container. Confirm build-time-only before you go further; if it isn't, the evaluation is over.config:cache is the highest-probability breakage point. Service providers that resolve asset paths at boot can bake absolute paths into the cached config, producing production-only 404s. Test the full deploy sequence, not artisan serve.diff the output directory.asset() with bundled paths. If a hashed filename is in play, asset('assets/app.css') resolves to the unhashed or stale path. Every reference must go through the package's directive or helper. Grep the codebase for hardcoded public/assets strings before you flip the switch.@asset will shadow or be shadowed by framework/other-package directives, and the failure is a silently unrendered asset or a PHP parse error inside a compiled view. Clear storage/framework/views after install and check php artisan view:cache passes.config('asset-bundle')), confirm the output directory exists and is readable by the web user, confirm the build command actually ran in that deploy, then log the final resolved path from the directive. In that order — path resolution, not minification, is almost always the culprit.bootstrap/providers.php, replace N directives in layouts with @vite. Count N. If N is large and scattered, that number is your real lock-in, and it's the number the decision should weigh.How can I help you explore Laravel packages today?