php - Yii2: Common Assets with Advanced Configuration -


i use yii2's advanced configuration separate frontend, backend, common , console applications. i've got many common assets, including stylesheets, js files, , fonts used in both frontend , backend applications. makes sense put assets in assets folder in common.

then, quandry starts. seems need separate appasset.php file manage assets in frontend , backend portions of overall application because things different between two. (i'm not sure whether refer frontend, backend, etc. separate applications within overarching something, or call them sub-applications of big overarching application.) anyway, appears need 2 appasset managers. handle file conversions (scss→css example) , file compression myself, have no need configure asset manager that.

unfortunately, documentation on appasset , asset bundles not clear @ on how include specific files or directories in bundle. thing see how specify destinations using $css, $js, variables. input directories, see $sourcepath. mean have create separate bundle (and $sourcepath) every single javascript, css, image, etc. file. that's whole lot of bundles! surely there's way include multiple asset files in single bundle. can show me how?

well believe purpose of "bundle" let cherry-pick files want.

you don't need make different bundle each individual file.

for instance, in super simple custom assetmanager have this:

namespace frontend\assets; use yii\web\assetbundle; use yii\web\yiiasset;  class customasset extends assetbundle{     public $basepath = '@webroot';     public $baseurl = '@web';     public $css = [         'css/custom.css',         'css/custom_modals.css'     ]; } 

since 2 css folders/files located in frontend-section of project , customasset located there too, when register assetmanager go through $css array , add them header section. same $js array add if needed to. also, remember, files need in web-accessible folder.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -