1

I need your help guys. I changed directory for all Assets. It works properly, but not for bootstrap fonts.

For Ex: path for css and js file now is project/www/web_assets/all.css and Yii2 found them properly.

But it does not working for fonts. Yii2 is looking for fonts at wrong derictrory /var/www/tt_yii/web/assets/582582f3/fonts/glyphicons-halflings-regular.woff2.

2 Answers2

0

Bootstrap gets used at different places. It is already configured by default by the BootstrapAsset and is a dependency for other pre-defined assets. But you can override the default location.

Assuming you have the same file structure in web_assets as it can be found in 'vendor/bower-asset/bootstrap/dist' (contains folder css, fonts and js) you can add the following to your components configuration:

use yii\bootstrap\BootstrapAsset;

...

'components'          => [
   ...
    'assetManager' => [
        'bundles' => [
            BootstrapAsset::class => [
                'sourcePath' => null,
                'baseUrl'    => '@web/web_assets',
            ],
        ]
    ],
    ...
],

@web points to the web folder where the index.php and your web_assets directory file should exist as well. sourcePath gets set to null since baseUrl wouldn't be evaluated.

Further information about configuring the used bundles can be found at AssetManager::$bundles or in the guide.

Similar question is here.

robsch
  • 9,358
  • 9
  • 63
  • 104
0

Check you nginx settings. If there is a filetype list, you should insert these font types into it also:

location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|eot|svg|ttf|woff|woff2)$

(Duplicate of bootstrap icon fonts not loading )

szabozoltan
  • 629
  • 8
  • 13