2017 © Pedro Peláez
 

yii2-extension yii2-asset-minifier

Runtime minification and combination of asset files.

image

lajax/yii2-asset-minifier

Runtime minification and combination of asset files.

  • Monday, May 30, 2016
  • by lajax
  • Repository
  • 8 Watchers
  • 7 Stars
  • 1,192 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 6 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

Yii2 AssetMinifier

Runtime minification and combination of asset files., (*1)

Installation

Extension for runtime minification and combination of asset files (css, js), (*2)

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist lajax/yii2-asset-minifier "*"

or add, (*5)

"lajax/yii2-asset-minifier": "*"

to the require section of your composer.json file., (*6)

Usage

Config

Minimal Configuration

'bootstrap' => ['assetMinifier'],
'components' => [
    // ...
    'assetMinifier' => [
        'class' => \lajax\assetminifier\Component::className(),
    ],
    // ...
],
// ...

Full Configuration

'bootstrap' => ['assetMinifier'],
'components' => [
    // ...
    'assetMinifier' => [
        'class' => \lajax\assetminifier\Component::className(),
        'minifyJs' => true,                     // minify js files. [default]
        'minifyCss' => true,                    // minify css files [default]
        'combine' => true,                      // combine asset files. [default]
        'createGz' => false,                    // create compressed .gz file, (so the web server doesn’t need to
                                                // compress asset files on each page view). Requires
                                                // special web server configuration. [default]
        'minifier' => [                         // Settings of the components performing the minification of asset files
            'workPath' => lajax\assetminifier\Minifier::WORKPATH_SOURCE, // default setting
            'js' => '', // override default minifier, see available minifiers below
            'css' => '', // override default minifier, see available minifiers below
        ],
        'combiner' => [
            'class' => 'lajax\assetminifier\Combiner',
            'combinedFilesPath' => '/lajax-asset-minifier'      // default setting
        ]
    ],
    // ...
]
// ...

AVAILABLE MINIFIERS:

  • #WEB:
'js' => [                           // minify js via web API
    'class' => 'lajax\assetminifier\minifiers\WebJsMinifier',
    'url' => 'http://javascript-inifier.com/raw'   // default setting
],
'css' => [
    'class' => 'lajax\assetminifier\minifiers\WebCssMinifier',
    'url' => 'http://cssminifier.com/raw'           // default setting
]
  • #PHP (Default minifiers):
'js' => [                                        // Default JS minifier.
    'class' => 'lajax\assetminifier\minifiers\PhpJsMinifier',
    // default settings, you can override them
    'options' => [
       'flaggedComments' => true                // Disable YUI style comment preservation.
    ]
],
'css' => [                                       // Default CSS minifier.
    'class' => 'lajax\assetminifier\minifiers\PhpCssMinifier',
    // default settings, you can override them
    'filters' => [
        'ImportImports' => false,
        'RemoveComments' => true,
        'RemoveEmptyRulesets' => true,
        'RemoveEmptyAtBlocks' => true,
        'ConvertLevel3AtKeyframes' => false,
        'ConvertLevel3Properties' => false,
        'Variables' => true,
        'RemoveLastDelarationSemiColon' => true
    ],
    'plugins' => [
        'Variables' => true,
        'ConvertFontWeight' => true,
        'ConvertHslColors' => true,
        'ConvertRgbColors' => true,
        'ConvertNamedColors' => true,
        'CompressColorValues' => true,
        'CompressExpressionValues' => true,
    ]
]
  • #CLI:
'js' => [
    'class' => 'lajax\assetminifier\minifiers\CliJsMinifier',
    // default settings, you can override them
    'command' => 'java -jar ' . Yii::getAlias('@vendor/packagist/closurecompiler-bin/bin/compiler.jar') . ' --js {from}',
],
'css' => [
    'class' => 'lajax\assetminifier\minifiers\CliCssMinifier',
    // default settings, you can override them
    'command' => 'java -jar ' . Yii::getAlias('@vendor/packagist/yuicompressor-bin/bin/yuicompressor.jar') . ' --type css {from}',
]

Minifiers

JavaScript minifiers:

StyleSheet minifiers:

Serving *.js.gz and *.css.gz files instead of *.js or *.css in Nginx:

gzip_static on | off | always

Nginx gzip static module, (*7)

The Versions

30/05 2016

dev-master

9999999-dev

Runtime minification and combination of asset files.

  Sources   Download

BSD-3-Clause

The Requires

 

by Lajos Molnar

css extension yii2 register js minify compress combine client script

22/02 2016

1.0.0

1.0.0.0

Runtime minification and combination of asset files.

  Sources   Download

BSD-3-Clause

The Requires

 

by Lajos Molnar

css extension yii2 register js minify compress combine client script