Yii2资产绑定转换较少的文件,但不';不发表

Yii2资产绑定转换较少的文件,但不';不发表,yii2,assets,Yii2,Assets,我有一个小部件,我想把一个较少的文件转换成一个css文件。 这种转换非常有效。但是现在我希望更少的文件不会发布到web/assets目录。 在这里疼痛开始了 这是我的代码: class BreadcrumbsAsset extends \yii\web\AssetBundle { public $css = [ 'css/breadcrumbs.less', ]; public $js = [ 'js/breadcrumbs.js',

我有一个小部件,我想把一个较少的文件转换成一个css文件。 这种转换非常有效。但是现在我希望更少的文件不会发布到
web/assets
目录。 在这里疼痛开始了

这是我的代码:

class BreadcrumbsAsset extends  \yii\web\AssetBundle
{
    public $css = [
        'css/breadcrumbs.less',
    ];

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

    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];

    public $publishOptions = [
        "only" => [
            "css/*",
            "js/*",
        ],
        'except' => [
            "doc/",
            "*.less",
        ],
    ];
}
但是使用
except
设置,css文件不会生成。 另外,当我尝试另一种方式并设置:

public $publishOptions = [
    "only" => [
        "css/*.css",
    ],
css文件不再从less文件生成。 那么这是如何工作的呢?


在这种情况下,如果仅添加了to选项和
除外

(AssetBundle不应发布.less或.coffee文件)

(AssetManager支持选择要发布的文件/目录)

Publishoptions的描述如下:

  • 仅限:数组,如果要复制文件路径,则文件路径应匹配的模式列表
  • 除外:数组,如果要从复制中排除文件或目录,则文件或目录应匹配的模式列表
在用于文件发布的Filehelper中,
除外
如下描述(来自Yii2 Filehelper源):


那么这个
之外的设置应该如何工作呢?
还是这是一个Bug?


忘了提一下,我当然安装了最新的yii2版本(yii2.0.6引入了publishOptions的唯一和例外设置)

例外
选项在转换前工作,因此,如果排除要转换的文件,则不会明显处理该文件。我不确定,但唯一的方法可能是扩展AssetConverter,以便在转换后删除
less
文件。但这里明确提到的这两个选项是用2.06修复的,并且添加了:这看起来不像是正确修复的问题<代码>更少
文件仍然存在。很好,你重新打开了它,也许我遗漏了一些东西。我想这些选项只有在css文件夹中没有更少的文件时才起作用。这样就可以排除完整的文件夹。例如,如果css文件由grunt或perhapts通过控制台资产控制器在外部生成。如果只为发布而不为转换处理除此之外的文件,这将是很好的。不,无论存在什么文件,选项都有效。这里的问题是处理顺序,就像我在第一条评论中所说的。
除外
选项在转换之前有效,因此如果排除要转换的文件,则显然不会对其进行处理。我不确定,但唯一的方法可能是扩展AssetConverter,以便在转换后删除
less
文件。但这里明确提到的这两个选项是用2.06修复的,并且添加了:这看起来不像是正确修复的问题<代码>更少
文件仍然存在。很好,你重新打开了它,也许我遗漏了一些东西。我想这些选项只有在css文件夹中没有更少的文件时才起作用。这样就可以排除完整的文件夹。例如,如果css文件由grunt或perhapts通过控制台资产控制器在外部生成。如果只为发布而不为转换处理除此之外的文件,这将是很好的。不,无论存在什么文件,选项都有效。这里的问题是处理顺序,就像我在第一条评论中说的那样。
- `except`: array, list of patterns excluding from the results matching file or directory paths.
  Patterns ending with slash ('/') apply to directory paths only, and patterns not ending with '/'
  apply to file paths only. For example, '/a/b' matches all file paths ending with '/a/b';
  and `.svn/` matches directory paths ending with `.svn`.
  If the pattern does not contain a slash (`/`), it is treated as a shell glob pattern
  and checked for a match against the pathname relative to `$dir`.
  Otherwise, the pattern is treated as a shell glob suitable for consumption by `fnmatch(3)`
  `with the `FNM_PATHNAME` flag: wildcards in the pattern will not match a `/` in the pathname.
  For example, `views/*.php` matches `views/index.php` but not `views/controller/index.php`.
  A leading slash matches the beginning of the pathname. For example, `/*.php` matches `index.php` but not `views/start/index.php`.
  An optional prefix `!` which negates the pattern; any matching file excluded by a previous pattern will become included again.
  If a negated pattern matches, this will override lower precedence patterns sources. Put a backslash (`\`) in front of the first `!`
  for patterns that begin with a literal `!`, for example, `\!important!.txt`.
  Note, the '/' characters in a pattern matches both '/' and '\' in the paths.

- `only`: array, list of patterns that the file paths should match if they are to be returned. Directory paths
  are not checked against them. Same pattern matching rules as in the `except` option are used.
  If a file path matches a pattern in both `only` and `except`, it will NOT be returned.