yii2 @bower 无法从 assetbundle 文件解析

yii2 @bower does not resolve from assetbundle file

Yii2 应用程序将 js 文件移动到 frontend/assets 中的 AppAsset.php 文件。但是,@bower 不会解析为别名。

namespace frontend\assets;

use yii\web\AssetBundle;

/**
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [ 
        'css/site.css',
    ];  
    public $js = [ 
        'js/script.js',
        '@bower/angular/angular.min.js',
        '@bower/angular-ui-router/release/angular-ui-router.min.js',
        '@bower/angular-bootstrap/ui-bootstrap.min.js'
    ];  
    public $depends = [ 
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
        'yii\web\JQueryAsset',
    ];  

}

浏览器在 http://localhost.lq/@bower/angular/angular.min.js

上给出 404

您应该创建新资产并像那样设置 $sourcePath 代码

    class AngularAsset extends AssetBundle
    {
        public $sourcePath = '@bower/angular';
        public $js = [

            'angular.min.js',
        ];
        public $depends = [
        'frontend\assets\AppAsset',
        ];
    }

    class AngularRouterAsset extends AssetBundle
        {
            public $sourcePath = '@bower/angular-ui-router';
            public $js = [
                'release/angular-ui-router.min.js',
            ];
            public $depends = [
            'frontend\assets\AppAsset',
            ];
        }

class AngularBootstrapAsset extends AssetBundle
        {
            public $sourcePath = '@bower/angular-ui-router';
            public $js = [
                'release/ui-bootstrap.min.js',
            ];
            public $depends = [
            'frontend\assets\AppAsset',
            ];
        }
    class AngularAllAsset extends AssetBundle
            {
                public $sourcePath = '@bower/angular-ui-router';
                public $js = [
                    'js/script.js',
                ];
                public $depends = [
                'frontend\assets\AppAsset',
                'frontend\assets\AngularAsset',
                'frontend\assets\AngularRouterAsset',
                'frontend\assets\AngularBootstrapAsset',
                ];
            }