I'm currently struggling with this requirement: We've got a modular app which where modules can be enabled by the customer on demand. Each module is a bundle. Now we've got some kind of dashboard where I'd like to inject assets (JS/CSS) based on the modules/bundles installed. In addition I'd like to merge those files into a single "dashboard.{js|css}" file so that we don't have 1 request per each bundles js and css file.
For other files we use a combination of Twig's Assetic integration and named assets, but it doesn't seem that the configuration key assetic.assets
can be accessed publically in a bundle's extension class... which is a pity as it'd be an awesome easy way for our approach.
I also looked into a custom config/service couple to inject an asset loader into assetics AssetManager
service... but this feels like a total overkill and I think that I simply missed something.
Any idea?
Update 1
I'm aiming for the following configuration:
assetic: # Assetic Configuration
assets:
dashboard_js:
inputs:
- '@ModuleOneBundle/Resources/public/js/dashboard.js'
- '@ModuleTwoBundle/Resources/public/js/dashboard_dep.js'
- '@ModuleTwoBundle/Resources/public/js/dashboard.js'
- '@ModuleThreeBundle/Resources/public/js/dashboard.js'
Our customers can decide which modules they use and therefore I cannot hardcode them. So I was trying to use the Configuration
classes, but they don't have access to what I need. I'd like to prevent to run custom build scripts to create config.yml
files.