interitty/assets-manager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

interitty/assets-manager

最新稳定版本:v1.0.7

Composer 安装命令:

composer require interitty/assets-manager

包简介

Manager with Latte macro that helps to properly load CSS/JS assets.

README 文档

README

Manager with Latte macro that helps to properly load CSS/JS assets.

Useful for assets cache busting in the production environment. In the development environment for work with Browsersync, the original path of the asset is rendered.

Requirements

Installation

The best way to install interitty/assets-manager is using Composer:

composer require interitty/assets-manager

Then register the extension in the Nette config file:

# app/config/config.neon
extensions:
    assetsManager: Interitty\AssetsManager\Nette\DI\AssetsManagerExtension

Usage

Macro can be used in any Latte template:

{* app/presenters/templates/@layout.latte *}
<link rel="stylesheet" href="{asset css/asset.css}">
<script src="{asset js/asset.js}"></script>

It prepends the path with `$assetBasePath` and loads revision from the revision manifest:

<link rel="stylesheet" href="/assets/css/asset.aHR0cHM6Ly9nb28uZ2wvS1ZRNHpT.css}">
<script src="/assets/js/asset.aHR0cHM6Ly9nb28uZ2wveFZqZHM0.js"></script>

Revision manifest

The revision manifest is a JSON file that contains the revision path of the asset.

It can be generated by various asset processors such as gulp or other similar tools.

Revision manifest is searched in the `$manifestPath`.

The path to revision manifest can be set directly:

# app/config/config.neon
assetsManager:
    assetBasePath: /assets/
    manifestPath: %wwwDir%/assets/manifest.json

Revision manifest may contain the asset path.

Asset version in the file name

With this method, the files have a different name at each change.

Example revision manifest:

{
    "css/asset.css": "css/asset.aHR0cHM6Ly9nb28uZ2wvS1ZRNHpT.css",
    "js/asset.js": "js/asset.aHR0cHM6Ly9nb28uZ2wveFZqZHM0.js"
}

With the example manifest, the code {asset "js/asset.js"} generates: /assets/js/asset.aHR0cHM6Ly9nb28uZ2wveFZqZHM0.js path.

Configuration

The default configuration, that can be changed to suit your needs:

# app/config/config.neon
assetsManager:
    assetBasePath: ''
    manifestPath: ''
    productionMode: %productionMode%
    wwwDir: %wwwDir%

统计信息

  • 总下载量: 207
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固