granam/web-content-builder

从HTML文件、markdown或PHP脚本构建HTML

安装次数: 385

依赖者: 7

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:composer-plugin

2.3.2 2022-01-03 15:04 UTC

README

注入资产版本

CSS示例

在CSS文件中注入图像md5总和的示例。

$assetsVersion = new \Granam\WebContentBuilder\AssetsVersion(); // will scan for *.css, *.html and *.md by default,

/** body {
    background-image: url("/img/someone.jpeg");
} */
echo file_get_contents(__DIR__ . '/css/main.css');

$changedFiles = $assetsVersion->addVersionsToAssetLinks(
    __DIR__ /* as document root */,
    ['css' ]/* to document root relative dirs to scan */,
    []/* no dirs to exclude */,
    []/* no exact files to scan */,
    false /* no dry run to change files directly */
);
/** Array (
    [0] => '/home/jaroslav/projects/granam/web-content-builder/css/main.css'
) */
print_r($changedFiles);


/** body {
    background-image: url("/img/someone.jpeg?version=664a924915e642c7dc89af370114629a");
} */
echo file_get_contents(__DIR__ . '/css/main.css');
echo md5_file(__DIR__ . '/img/someone.jpeg'); // 664a924915e642c7dc89af370114629a