首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yii2资产在发布时排除文件和目录

Yii2资产在发布时排除文件和目录
EN

Stack Overflow用户
提问于 2016-09-23 19:19:18
回答 1查看 981关注 0票数 1

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

源文件夹如下所示:

代码语言:javascript
复制
/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

资产包如下所示

代码语言:javascript
复制
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',
        ],
    ];
}

最后,web资源文件夹中的结果如下所示

代码语言:javascript
复制
./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

是否仍在复制空文件夹??我如何防止这种情况发生?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-23 20:21:26

thx soju,那是个打字错误:

通过下面的发布选项,它可以正常工作

代码语言:javascript
复制
public $publishOptions = [
//        'forceCopy' => YII_DEBUG,
        'only' => [
            'animate.min.css',
        ],
        'except' => [
            'source',
        ],
    ];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39659506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档