vicvicos/yii2-min-view

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

安装: 2

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

类型:yii2-extension

1.15.2 2020-05-22 10:57 UTC

This package is auto-updated.

Last update: 2024-09-16 06:32:58 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 vicvicos/yii2-minify-view

或者

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

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

配置

<?php

return [
	// ...
	'components' => [
		// ...
		'view' => [
			'class' => '\vicvicos\yii\minify\View',
			'enableMinify' => !YII_DEBUG,
			'concatCss' => true, // concatenate css
			'minifyCss' => true, // minificate css
			'concatJs' => true, // concatenate js
			'minifyJs' => true, // minificate js
            'cssOptions' => [ // Options css
                "preload" => true // preload css files
            ],
			'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
            ],
		]
	]
];

原始: https://github.com/rmrevin/yii2-minify-view 以及 VicVicos 的一些小修改