【问题标题】:Yii2 Assets Exclude Files, Directories on publishingYii2 资产排除文件、发布目录
【发布时间】:2016-09-23 11:19:18
【问题描述】:

我想发布一些 Asstes。例如由 bower 或 composer 下载的 animate.css,但我不想将不需要的文件复制到 web asstes 文件夹中。 我已经使用了发布选项,但无论如何都会复制一些文件夹,但没有内容。

源文件夹如下所示:

/animate.css
./bower.json
./source
./source/bouncing_exits
./source/bouncing_exits/bounceOutLeft.css
./source/bouncing_exits/bounceOutDown.css
./source/bouncing_exits/bounceOutUp.css
./source/bouncing_exits/bounceOutRight.css
./source/bouncing_exits/bounceOut.css
./source/fading_exits
./source/fading_exits/fadeOutRight.css
./source/fading_exits/fadeOutLeft.css
./source/fading_exits/fadeOutDown.css
./source/fading_exits/fadeOutUp.css
./source/fading_exits/fadeOutLeftBig.css
./source/fading_exits/fadeOut.css
./source/fading_exits/fadeOutRightBig.css
./source/fading_exits/fadeOutDownBig.css
./source/fading_exits/fadeOutUpBig.css
./source/fading_entrances
./source/fading_entrances/fadeInRight.css
./source/fading_entrances/fadeInUp.css
... some more
./animate-config.json
./package.json
./gulpfile.js
./animate.min.css
./LICENSE

资产包看起来像这样

namespace frontend\assets;

use yii\web\AssetBundle;

/**
 * Main frontend application asset bundle.
 */
class AnimateAsset extends AssetBundle
{
    /**
     * @inherit
     */
    public $sourcePath = '@bower/animate.css';

    /**
     * @inherit
     */
    public $css = [ 
        'animate.min.css',
    ];

    /**
     * @inherit
     */
    public $js = [
    ];

    /**
     * @inherit
     */
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
        'yii\bootstrap\BootstrapPluginAsset',
    ];


       public $publishOptions = [
//        'forceCopy' => YII_DEBUG,
        'only' => [
            'animate.min.css',
        ],
        'exept' => [
            'source/*',
            'source/',
            'source',
        ],
    ];
}

最终网页资源文件夹中的结果如下所示

./source
./source/bouncing_exits
./source/fading_exits
./source/fading_entrances
./source/lightspeed
./source/zooming_entrances
./source/zooming_exits
./source/bouncing_entrances
./source/rotating_entrances
./source/attention_seekers
./source/sliding_exits
./source/rotating_exits
./source/flippers
./source/specials
./source/sliding_entrances
./animate.min.css

空文件夹还被复制?? 我怎样才能防止这种情况发生?

【问题讨论】:

  • 你应该简单地尝试except而不是exept
  • 非常感谢!!效果非常好;)

标签: php yii2 assets


【解决方案1】:

thx 烧酒,打错字了:

使用下面的发布选项就可以了

public $publishOptions = [
//        'forceCopy' => YII_DEBUG,
        'only' => [
            'animate.min.css',
        ],
        'except' => [
            'source',
        ],
    ];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-07
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2017-05-03
    • 2014-09-09
    • 2017-07-18
    相关资源
    最近更新 更多