I see that to implement named assets one must first declare it here. Is there a way to have multiple js files loaded with one name?
Sure it can take an array of both js and css assets. You can see this in the bootstrapper plugin where we are building an array based on some config options.
Thank you for your quick response!
How can I declare my css and js in the system.yaml file? I don’t want to have a plugin as some of the css files wouldn’t be called on every page. I’d rather it be included in the core and have the option to turn certain css files off/on with twig, or page headers.
Currently we call named assets like so:
Would that be the same with CSS included? Or is this a good time to use something like
How would this look with css files included?
assets:
css_pipeline: false
css_minify: true
css_minify_windows: false
css_rewrite: true
js_pipeline: false
js_minify: true
collections:
jquery: system://assets/jquery/jquery-2.1.3.min.js
The addJs()
and addCss()
methods actually call the add()
method for named collections because you can have a mix of CSS and JS files in the collection. If you wanted to define a collection via the system.yaml
file you could have something like:
assets:
collections:
jquery: system://assets/jquery/jquery-2.1.3.min.js
mycol:
- theme://css/mycol.css
- theme://js/mycol.js
- http://something/else.css
- http://another/url.css
Then simple add the collection via:
{{ do assets.add('mycol') }}
---