axllent/silverstripe-minifier 问题修复 & 功能扩展

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

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

axllent/silverstripe-minifier

最新稳定版本:2.0.1

Composer 安装命令:

composer require axllent/silverstripe-minifier

包简介

CSS & JavaScript minifier for Silverstripe

README 文档

README

Automatically minify combined CSS & JavaScript files in Silverstripe 5 when running Requirements::process_combined_files(). Internally it uses matthiasmullie/minify to remove whitespace, strips comments and combines files.

This is useful if you do not require any JavaScript bundling or transpiling (eg: webpak, esbuild etc) but you still wish to minify the combined CSS and JavaScript files.

Requirements

  • Silverstripe ^5

Installation

composer require axllent/silverstripe-minifier

This module is plug-and-play, no configuration required after installing and running a ?flush.

Usage example

<?php

use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\View\Requirements;

class PageController extends ContentController
{
    /**
     * Init function
     *
     * @return void
     */
    protected function init()
    {
        parent::init();

        $css[] = 'themes/site/css/file1.css';
        $css[] = 'themes/site/css/file2.css';
        $css[] = 'themes/site/css/file3.css';
        Requirements::combine_files('combined.css', $css);
        Requirements::process_combined_files();

        $js[] = 'themes/site/js/file1.js';
        $js[] = 'themes/site/js/file2.js';
        $js[] = 'themes/site/js/file3.js';
        Requirements::combine_files('combined.js', $js);
        Requirements::process_combined_files();
    }
}

统计信息

  • 总下载量: 22.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-09