tapestry-cloud / asset-plugin
Tapestry 的资源插件
1.1.1
2019-08-23 21:15 UTC
Requires
- php: >=7.2
- ext-json: *
Requires (Dev)
- phpunit/phpunit: 5.7.*
- tapestry-cloud/tapestry: ^1.0
This package is auto-updated.
Last update: 2024-09-24 08:43:06 UTC
README
相当于 Laravel 的 mix()
安装
要安装,请运行: composer require tapestry-cloud/asset-plugin
接下来,您需要更新网站配置,包括 manifest.json 的路径
// ... 'plugins' => [ 'asset_manifest_path' => __DIR__ . '/rev-manifest.json' ], // ...
最后,在您的 site Kernel.php 中注册插件的ServiceProvider
<?php use Tapestry\Modules\Kernel\KernelInterface; class Kernel implements KernelInterface { /** * @var Tapestry */ private $tapestry; public function __construct(Tapestry $tapestry) { $this->tapestry = $tapestry; } /** * This method is executed by Tapestry when the Kernel is registered. * * @return void */ public function register() { // Use project autoloader require_once(__DIR__ . '/vendor/autoload.php'); } /** * This method of executed by Tapestry as part of the build process. * * @return void */ public function boot() { $this->tapestry->register(\TapestryCloud\Asset\ServiceProvider::class); } }
用法
此插件添加了 $this->asset('main.css')
辅助函数,当与生成 manifest.json 文件的 gulp 或 grunt 任务配合使用时,用于映射资源修订版本,这意味着您每次构建 CSS/JS 资产时无需更新 HTML 源代码。