Answer the question
In order to leave comments, you need to log in
Yii2 + Twig. Do I need to use AssetBundle?
All the best. I opened this miracle framework. Everything is smart, convenient and fast. Raised the first site and realized that using a custom approach with php templates is not comme il faut. It’s hard for the layout designer, it hurts the eye, etc.
I screwed Twig, Bower and started rendering all this stuff. And ran into AssetsBundle. On the one hand, this is very convenient for me, as a back-end developer, on the other hand, it twitches every time because the front-end requires you to connect a slider or something else quite expensive. It's much easier to outsource the free insertion of scripts/styles directly into Twig templates.
In connection with this, a question arose. Which approach is relevant in terms of Best Practice in Yii2?
Answer the question
In order to leave comments, you need to log in
namespace frontend\assets;
class AppAsset extends AssetBundle
{
public $sourcePath = '@frontend/resource';
public $css = [
'css/site.css',
];
public $depends = [
'yii\web\JqueryAsset',
];
}
namespace frontend\widgets\FlexSlider;
class SliderAsset extends AssetBundle
{
public $sourcePath = '@vendor/bower/flexslider';
public $css = [
// 'flexslider.css'
];
public $js = [
'jquery.flexslider.js'
];
public $depends = [
'frontend\assets\AppAsset',
'yii\web\JqueryAsset',
];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question