cundd/assetic 问题修复 & 功能扩展

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

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

cundd/assetic

Composer 安装命令:

composer require cundd/assetic

包简介

Assetic for TYPO3 CMS

README 文档

README

Integrate the Assetic asset management framework into your TYPO3 CMS installation.

Installation

  1. composer require cundd/assetic
  2. Load the Site Set into the TYPO3 Site
  3. Configure the assets you want to be loaded
  4. Include the plugin the page.headerData
    // Example:
    page.headerData.40001 =< plugin.tx_assetic
    

Usage

Basic

# File: config/sites/my-site/settings.yaml or EXT:site_package/Configuration/Sets/Site/settings.yaml
assetic:
    stylesheets:
        - file: EXT:site_package/Resources/Private/Stylesheets/main.css

Multiple assets

# File: config/sites/my-site/settings.yaml or EXT:site_package/Configuration/Sets/Site/settings.yaml
assetic:
    stylesheets:
        - file: EXT:site_package/Resources/Private/Stylesheets/reset.css
        - file: EXT:site_package/Resources/Private/Stylesheets/style.css

With SASS

If your web server and web user are configured to be able to use the sass command line tool, from within your TYPO3 installation, you could use the following:

# File: config/sites/my-site/settings.yaml or EXT:site_package/Configuration/Sets/Site/settings.yaml
assetic:
    stylesheets:
        - file: EXT:site_package/Resources/Private/Stylesheets/main.scss

With other CSS preprocessors

Analog you can use other CSS preprocessors. The Assetic Github Page provides a (incomplete) list of all filters provided by the installed Assetic version.

Development mode

To make sure that the assets are compiled each time the frontend page is refreshed, you can enable the development mode:

plugin.tx_assetic {
    development = 1
}

By default Cundd Assetic is configured not to compile files if NO backend user is logged in. To allow file compilation without a logged in backend user you can change the allowDeveloperFeaturesWithoutLogin configuration in Site Settings.

Advanced

Configure a filter

Some filters allow further customization. The Sass filter e.g. provides the method addImportPath which allows you to add another path to look for imported Sass files. Cundd Assetic provides an interface to invoke such functions.

# File: config/sites/my-site/settings.yaml or EXT:site_package/Configuration/Sets/Site/settings.yaml
assetic:
    stylesheets:
        - file: EXT:site_package/Resources/Private/Stylesheets/main.scss
          functions:
              # Add functions that will be called on the filter
              addImportPath: ProjectPath:/vendor/

If you want to invoke a method multiple times you can just add a numeric prefix to the function name:

# File: config/sites/my-site/settings.yaml or EXT:site_package/Configuration/Sets/Site/settings.yaml
assetic:
    stylesheets:
        - file: EXT:site_package/Resources/Private/Stylesheets/main.scss
          functions:
              # Add a numeric prefix to allow the function to called multiple times
              0-addImportPath: ProjectPath:/vendor/
              1-addImportPath: EXT:site_package/Resources/Private/Library/

Development flags

To apply functions only in development mode, entries can be added with key developmentFunctions:

# File: config/sites/my-site/settings.yaml or EXT:site_package/Configuration/Sets/Site/settings.yaml
assetic:
    stylesheets:
        - file: EXT:site_package/Resources/Private/Stylesheets/main.scss
          functions:
              setStyle: compressed

          developmentFunctions:
              setStyle: expanded

Configure the filter binary paths

In some cases you may have to specify the path to a CSS preprocessor to match your system's configuration. This can be done through the filterBinaries configuration.

The configuration keys are determined by replacing \ with _ and converting the string to lowercase:

1. \AsseticAdditions\Filter\DartSassFilter
2. AsseticAdditions_Filter_DartSassFilter
3. asseticadditions_filter_dartsassfilter
# File: config/sites/my-site/settings.yaml or EXT:site_package/Configuration/Sets/Site/settings.yaml
assetic:
    settings:
        filterBinaries:
            # Change the path to the filter binaries. I.e. if node.js is installed
            # into /usr/local/bin/
            assetic_filter_lessfilter: /usr/local/bin/node

            # The binary for filter class \AsseticAdditions\Filter\DartSassFilter
            asseticadditions_filter_dartsassfilter: /usr/local/bin/sass

Command line

Assetic provides three different CLI commands.

assetic:compile

Compiles the assets and exit.

vendor/bin/typo3 assetic:compile

assetic:watch

Watches for file changes in EXT:client and re-compiles the assets if needed.

vendor/bin/typo3 assetic:watch

assetic:livereload

Starts a LiveReload compatible server that watches for file changes in EXT:client and re-compiles the assets if needed. The necessary JavaScript can be loaded be enabling addJavascript in Site Settings.

vendor/bin/typo3 assetic:livereload

LiveReload

Setup

To start the LiveReload server "Add LiveReload JavaScript" (assetic.settings.livereload.addJavascript) must be enabled in site settings and the PHP library "Ratchet" must be installed. For example as a development dependency:

  "require-dev": {
    "cboden/ratchet": "^0.4.x-dev"
  }

LiveReload & CSP

To use LiveReload with CSP enabled add wss://your-domain.tld:35729/livereload to connect-src in the site's CSP configuration file (config/sites/your-site/csp.yaml).

See the TYPO3 documentation for further details.

Example

mutations:
    - mode: "extend"
      directive: "connect-src"
      sources:
          - "wss://your-domain.tld:35729/livereload"

Additional tools

Standalone auto-refresh tool

Cundd Assetic provides a JavaScript tool that checks the CSS and JavaScript assets on the page for changes and automatically reloads them. For more information and usage visit /Resources/Public/JavaScript.

Sponsored by

cundd/assetic 适用场景与选型建议

cundd/assetic 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 332 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 07 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「assets」 「compression」 「minification」 「typo3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cundd/assetic 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cundd/assetic 我们能提供哪些服务?
定制开发 / 二次开发

基于 cundd/assetic 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-04