Property | Type | Description | |
---|---|---|---|
$bundles | list of asset bundles to be compressed. | ||
$cssCompressor | CSS file compressor. If a string, it is treated as shell command template, which should contain placeholders {from} - source file name - and {to} - output file name. Otherwise, it is treated as PHP callback, which should perform the compression. Default value relies on usage of "YUI Compressor" | ||
$defaultAction | controller default action ID. | ||
$deleteSource | whether to delete asset source files after compression. This option affects only those bundles, which have [[\yii\web\AssetBundle::sourcePath]] is set. | ||
$jsCompressor | JavaScript file compressor. If a string, it is treated as shell command template, which should contain placeholders {from} - source file name - and {to} - output file name. Otherwise, it is treated as PHP callback, which should perform the compression. Default value relies on usage of "Closure Compiler" | ||
$targets | list of asset bundles, which represents output compressed files. You can specify the name of the output compressed file using 'css' and 'js' keys: For example: php 'app\config\AllAsset' => [ 'js' => 'js/all-{hash}.js', 'css' => 'css/all-{hash}.css', 'depends' => [ ... ], ] File names can contain placeholder "{hash}", which will be filled by the hash of the resulting file. You may specify several target bundles in order to compress different groups of assets. In this case you should use 'depends' key to specify, which bundles should be covered with particular target bundle. You may leave 'depends' to be empty for single bundle, which will compress all remaining bundles in this case. For example: php 'allShared' => [ 'js' => 'js/all-shared-{hash}.js', 'css' => 'css/all-shared-{hash}.css', 'depends' => [ Include all assets shared between 'backend' and 'frontend' 'yii\web\YiiAsset', 'app\assets\SharedAsset', ], ], 'allBackEnd' => [ 'js' => 'js/all-{hash}.js', 'css' => 'css/all-{hash}.css', 'depends' => [ Include only 'backend' assets: 'app\assets\AdminAsset' ], ], 'allFrontEnd' => [ 'js' => 'js/all-{hash}.js', 'css' => 'css/all-{hash}.css', 'depends' => [], // Include all remaining assets ], |
Method | Description | |
---|---|---|
actionCompress ( string $configFile, string $bundleFile ) | Combines and compresses the asset files according to the given configuration. | |
actionTemplate ( string $configFile ) : integer | Creates template of configuration file for [[actionCompress]]. | |
combineCssFiles ( array $inputFiles, string $outputFile ) | Combines CSS files into a single one. | |
combineJsFiles ( array $inputFiles, string $outputFile ) | Combines JavaScript files into a single one. | |
getAssetManager ( ) : |
Returns the asset manager instance. | |
setAssetManager ( |
Sets asset manager instance or configuration. |
Method | Description | |
---|---|---|
adjustCssUrl ( string $cssContent, string $inputFilePath, string $outputFilePath ) : string | Adjusts CSS content allowing URL references pointing to the original resources. | |
adjustDependency ( |
Adjust dependencies between asset bundles in the way source bundles begin to depend on output ones. | |
buildTarget ( |
Builds output asset bundle. | |
compressCssFiles ( array $inputFiles, string $outputFile ) | Compresses given CSS files and combines them into the single one. | |
compressJsFiles ( array $inputFiles, string $outputFile ) | Compresses given JavaScript files and combines them into the single one. | |
loadBundles ( string[] $bundles ) : |
Creates full list of source asset bundles. | |
loadConfiguration ( string $configFile ) | Applies configuration from the given file to self instance. | |
loadDependency ( |
Loads asset bundle dependencies recursively. | |
loadTargets ( array $targets, |
Creates full list of output asset bundles. | |
registerBundle ( |
Registers asset bundles including their dependencies. | |
saveTargets ( |
Saves new asset bundles configuration. |
Method | Description | |
---|---|---|
composeBundleConfig ( |
||
composeCircularDependencyTrace ( string $circularDependencyName, array $registered ) : string | Composes trace info for bundle circular dependency. | |
deletePublishedAssets ( |
Deletes bundle asset files, which have been published from sourcePath. | |
findRealPath ( string $path ) : string | Returns canonicalized absolute pathname. | |
isBundleExternal ( |
public actionCompress ( string $configFile, string $bundleFile ) | ||
$configFile | string | configuration file name. |
$bundleFile | string | output asset bundles configuration file name. |
public actionTemplate ( string $configFile ) : integer | ||
$configFile | string | output file name. |
return | integer | CLI exit code |
protected adjustDependency ( |
||
$targets | output asset bundles. | |
$bundles | source asset bundles. | |
return | output asset bundles. |
protected buildTarget ( |
||
$target | output asset bundle | |
$type | string | either 'js' or 'css'. |
$bundles | source asset bundles. |
public combineCssFiles ( array $inputFiles, string $outputFile ) | ||
$inputFiles | array | source file names. |
$outputFile | string | output file name. |
public combineJsFiles ( array $inputFiles, string $outputFile ) | ||
$inputFiles | array | source file names. |
$outputFile | string | output file name. |
protected compressCssFiles ( array $inputFiles, string $outputFile ) | ||
$inputFiles | array | list of source file names. |
$outputFile | string | output file name. |
protected compressJsFiles ( array $inputFiles, string $outputFile ) | ||
$inputFiles | array | list of source file names. |
$outputFile | string | output file name. |
public getAssetManager ( ) : |
||
return | asset manager instance. |
protected loadBundles ( string[] $bundles ) : |
||
$bundles | string[] | list of asset bundle names |
return | list of source asset bundles. |
protected loadConfiguration ( string $configFile ) | ||
$configFile | string | configuration file name. |
protected loadDependency ( |
||
$bundle | bundle instance | |
$result | array | already loaded bundles list. |
protected loadTargets ( array $targets, |
||
$targets | array | output asset bundles configuration. |
$bundles | list of source asset bundles. | |
return | list of output asset bundles. |
protected registerBundle ( |
||
$bundles | asset bundles list. | |
$name | string | bundle name. |
$registered | array | stores already registered names. |
protected saveTargets ( |
||
$targets | list of asset bundles to be saved. | |
$bundleFile | string | output file name. |
public setAssetManager ( |
||
$assetManager | asset manager instance or its array configuration. |
public $cssCompressor |
public $deleteSource |
public $jsCompressor |
public $targets |