apnet/assetic-importer-bundle
Installation:
composer require apnet/assetic-importer-bundle
Add the bundle to AppKernel.php:
$bundles[] = new Apnet\AsseticImporterBundle\ApnetAsseticImporterBundle();
Basic Configuration (config.yml):
apnet_assetic_importer:
assets:
my_css:
source: %kernel.root_dir%/Resources/public/css
target: my_assets
Run asset dump:
php bin/console assetic:dump
First Use Case: Access files via Twig:
<link href="{{ imported_asset('my_assets/style.css') }}" rel="stylesheet">
Static Asset Integration:
source to point to a directory (e.g., app/Resources/public/css).imported_asset('target/filename').Dynamic Asset Compilation (Compass/Sass):
importer: compass and point source to config.rb.watcher in config_dev.yml for live reloading:
apnet_assetic_watcher:
enabled: true
compiler_root: %kernel.root_dir%/Resources
imported_asset('target/generated.css').Environment-Specific Routing:
target to namespace assets (e.g., vendor_assets).cssrewrite filter for non-public bundles (e.g., @VendorBundle).composer.json constraints).imported_asset in your Twig environment if needed:
$twig->addFunction(new \Twig_SimpleFunction('imported_asset', [$this->get('apnet_assetic_importer.twig.asset_url_generator'), 'generate']));
?v=1.0 to URLs for cache busting (handled by Assetic).Permission Issues:
compass_dir/stylesheets for live reloading.chmod -R 775 on the target directory.Assetic Dump Required:
php bin/console assetic:dump after config changes will break asset access.composer.json:
"scripts": {
"post-install-cmd": ["assetic:dump"]
}
CSS Rewrite Conflicts:
@Bundle syntax in CSS, disable cssrewrite filter in config.yml:
assetic:
filters:
cssrewrite: ~
Watcher Bundle:
AsseticWatcherBundle in dev (it’s disabled by default).Asset Not Found?:
source paths are correct (use absolute paths with %kernel.root_dir%).var/cache/dev for generated asset manifests.php bin/console debug:assetic to list available assets.Compass Errors:
config.rb is valid and dependencies (e.g., compass) are installed globally.compass compile path/to/config.rb.Custom Importers:
Apnet\AsseticImporterBundle\Importer\ImporterInterface for new build tools (e.g., PostCSS).services.yml:
services:
my_custom_importer:
class: AppBundle\Importer\MyImporter
tags:
- { name: apnet_assetic_importer.importer, alias: my_importer }
Asset URL Generation:
Apnet\AsseticImporterBundle\Twig\AssetUrlGenerator.Cache Invalidation:
php bin/console cache:clear && php bin/console assetic:dump
How can I help you explore Laravel packages today?