【问题标题】:Javascript in Yii2 AssetBundle is not published on updateYii2 AssetBundle 中的 Javascript 未在更新时发布
【发布时间】:2015-06-05 09:08:41
【问题描述】:

我有一个非常简单的 AssetBundle:

use yii\web\AssetBundle;

/**
 * ImagizerAsset
 */
class ImagizerAsset extends AssetBundle
{
    public $sourcePath = '@app/components/widgets/imagizer/assets';

    public $css = [
        'css/imagizer.css'
    ];

    public $js = [
        'js/imagizer.js',
    ];

    public $depends = [
        'app\assets\BowerCropperAsset'
    ];
}

如果我更改包中的 JavaScript,它不会在开发模式下发布到 web/asset 目录。每次我都必须删除 web/asset 目录才能获得最新版本。这很烦人。我该怎么办?

【问题讨论】:

标签: javascript yii2 assets assetbundle


【解决方案1】:

已经回复here

将此添加到您的资产包中:

public $publishOptions = [
    'forceCopy' => YII_DEBUG,
];

有关更多选项和详细说明,请查看链接答案。

【讨论】:

  • 我建议将其与环境联系起来,您真的不希望每次都这样做。 'forceCopy' => YII_ENV === 'dev' 并且你总是忘记在提交时将它们注释掉......
  • @Blizz 在链接答案中提到。
  • @Blizz 也在这里添加。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-05
  • 1970-01-01
  • 2013-08-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多