有兴趣的同学可以先看下官方原文档
文档样例代码
<?php namespace app\assets; use yii\web\AssetBundle; class FontAwesomeAsset extends AssetBundle { public $sourcePath = '@bower/font-awesome'; public $css = [ 'css/font-awesome.min.css', ]; public $publishOptions = [ 'only' => [ 'fonts/', 'css/', ] ]; }
官方文档给出的说明是,如此配置之后仅发布 fonts 及 css 资源目录
The above example defines an asset bundle for the "fontawesome" package.
By specifying the only publishing option,
only the fonts and css subdirectories will be published.
为什么是错误的呢, 因为无法实现官网文档说明的 发布 fonts 和 css 两个目录的需求。
正确的写法如下:
//... public $publishOptions = [ 'only' => [ 'fonts/*', 'css/*', ] ];