incenteev/hashed-asset-bundle

为 symfony/asset 应用基于资产哈希的版本

安装数: 438,271

依赖项: 1

建议者: 0

安全: 0

星标: 23

关注者: 4

分支: 4

开放问题: 0

类型:symfony-bundle

v1.5.0 2024-01-16 13:28 UTC

This package is auto-updated.

Last update: 2024-09-16 14:58:03 UTC


README

HashedAssetBundle 提供了一种资产版本策略,它使用文件内容的哈希值作为资产版本。这允许为每个资产单独(自动)提升版本。

CI Total Downloads Latest Stable Version

安装

使用 Composer 安装包

$ composer require incenteev/hashed-asset-bundle

使用方法

在内核中注册包

// app/AppKernel.php

// ...

class AppKernel extends Kernel {
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Incenteev\HashedAssetBundle\IncenteevHashedAssetBundle(),
        );
    }
}

然后配置 FrameworkBundle 以使用新的版本策略

framework:
    assets:
        version_strategy: incenteev_hashed_asset.strategy

高级配置

默认配置应该满足常见需求,但如果需要,包暴露了一些配置设置

incenteev_hashed_asset:
    # Absolute path to the folder in which assets can be found
    # Note: in case you apply a base_path in your asset package, it is not
    # yet applied to the string received by the bundle
    web_root: '%kernel.project_dir%/web'
    # Format used to apply the version. This is equivalent to the
    # `framework > assets > version_format` of the static version strategy
    # of FrameworkBundle.
    version_format: '%%s?%%s'

许可

此包遵循 MIT 许可

替代项目

如果您想在资产管道中通过重命名文件来应用缓存破坏(例如使用 webpack-encore 版本功能),请查看 Symfony 本身提供的 json_manifest 策略。

报告问题或功能请求

问题和功能请求在 Github 问题跟踪器 中跟踪。