rmrevin/yii2-minify-view

Yii2 视图组件,在运行时自动压缩 CSS 和 JS 文件

安装数: 237,976

依赖者: 15

建议者: 0

安全: 0

星标: 191

关注者: 14

分叉: 67

开放性问题: 10

类型:yii2-extension

2.0.0 2017-12-22 20:31 UTC

README

此组件的主要功能是通过 "AssetBundle" 连接文件进行合并和压缩。

License Latest Stable Version Latest Unstable Version Total Downloads

代码状态

Scrutinizer Code Quality Code Coverage Travis CI Build Status Dependency Status

支持

GitHub 问题公共聊天

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一:

composer require rmrevin/yii2-minify-view

或者

"rmrevin/yii2-minify-view": "^1.15",

将以下内容添加到您的 composer.json 文件的 require 部分。

配置

<?php

return [
	// ...
	'components' => [
		// ...
		'view' => [
			'class' => '\rmrevin\yii\minify\View',
			'enableMinify' => !YII_DEBUG,
			'concatCss' => true, // concatenate css
			'minifyCss' => true, // minificate css
			'concatJs' => true, // concatenate js
			'minifyJs' => true, // minificate js
			'minifyOutput' => true, // minificate result html page
			'webPath' => '@web', // path alias to web base
			'basePath' => '@webroot', // path alias to web base
			'minifyPath' => '@webroot/minify', // path alias to save minify result
			'jsPosition' => [ \yii\web\View::POS_END ], // positions of js files to be minified
			'forceCharset' => 'UTF-8', // charset forcibly assign, otherwise will use all of the files found charset
			'expandImports' => true, // whether to change @import on content
			'compressOptions' => ['extra' => true], // options for compress
			'excludeFiles' => [
            	'jquery.js', // exclude this file from minification
            	'app-[^.].js', // you may use regexp
            ],
            'excludeBundles' => [
            	\app\helloworld\AssetBundle::class, // exclude this bundle from minification
            ],
		]
	]
];