yanli0303/yii-minify-client-script 问题修复 & 功能扩展

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

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

yanli0303/yii-minify-client-script

最新稳定版本:0.2

Composer 安装命令:

composer require yanli0303/yii-minify-client-script

包简介

A PHP Yii framework extension to minify JavaScript and CSS files for a web page.

README 文档

README

By Yan Li

Build Status Coverage Status License PayPayl donate button

A PHP Yii framework extension to minify JavaScript and CSS files for a web page.

How does it work?

  1. Minify each JavaScript and CSS files before deployment (during build stage):
    • For each JavaScript/CSS file we have, generated a minified version in same directory, and name it with a .min suffix;
    • e.g. Minified version of ~/src/css/style.css should be named as ~/src/css/style.min.css
  2. Concatenate the JavaScript/CSS files required on the page at run-time

Usage

  1. Create a new extension directory for your Yii application: ~/protected/extensions/minify
  2. Download both src/MinifyClientScript.php and LICENSE.md, put them into ~/protected/extensions/minify
  3. Update your Yii application configuration file(usually named /protected/config/main.php) and replace the Yii CClientScript with MinifyClientScript
  4. Before deploying, minify the individual JavaScript and CSS files:
  5. Pack your application sources and deploy

Sample Yii application configuration file:

return array(
    'basePath' => __DIR__ . '/..',
    'name' => 'Your App Name',
    'preload' => array('log'),
    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.extensions.*'
    ),
    'clientScript' => array(
        'class' => 'ext.minify.MinifyClientScript',
        'minify' => !YII_DEBUG, // Disable minifying while developing
        // put all js files before end </body> tag
        // note this setting won't affect css files, they will be put in <head>
        'coreScriptPosition' => CClientScript::POS_END,
        'packages' => array(
            'home_page' => array(
                'baseUrl' => '',
                'js' => array(
                    'bower_components/jquery/jquery.js',
                    'bower_components/angular/angular.js',
                    'bower_components/bootstrap/dist/js/bootstrap.js',
                    'js/home/home_index.js'
                ),
                'css' => array(
                    'bower_components/bootstrap/dist/css/bootstrap.css',
                    'css/home/home_index.css'
                )
            )
        )
    )
);

NOTE

It requires sticky session from load balance server, otherwise you'll encounter HTTP 404 problems.

Alternatives

统计信息

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

GitHub 信息

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

其他信息

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