About the correct posture of $ publishOptions in Yii2 AssetBundle, yii2assetbundle

Source: Internet
Author: User

About the correct posture of $ publishOptions in Yii2 AssetBundle, yii2assetbundle

This article describes how to use the correct posture of $ publishOptions in Yii2 AssetBundle. The details are as follows:

Official documents: http://www.yiiframework.com/doc-2.0/guide-structure-assets.html

If you are interested, you can read the original document of the official website.

Sample Code

<?phpnamespace 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/',    ]  ];}

The official documentation shows that only the fonts and css resource directories are published after such configuration.

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.

Why is it wrong, because it is unable to meet the requirements for publishing the fonts and css directories described in the official website documentation.

The correct syntax is as follows:

//...  public $publishOptions = [    'only' => [      'fonts/*',      'css/*',    ]  ];

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.