Cakeminify plugin for CakePHP
combine and compress your web asset resource in cakephp3+, (*1)
Installation
You can install this plugin into your CakePHP application using composer., (*2)
The recommended way to install composer packages is:, (*3)
composer require visonforcoding/cakeminify
Config
config your asset resource,create a config file named
minify.php in config directory。, (*4)
return[
'minjs'=>[
'source'=>[
'/asset/jquery/dist/jquery.js',
'/asset/zui/dist/js/zui.js',
'/asset/vue/dist/vue.js'
],
'desc'=>'/dist/main.js'
],
'mincss'=>[
'source'=>[
'/asset/zui/dist/css/zui.css',
'/css/view.css',
],
'desc'=>'/dist/default.css'
],
];
shell
combine and compress, (*5)
bin/cake minify start
the combine file will create in your 'desc' config, (*6)
helper
call the helper function in your template, (*7)
<?= $this->minify->generateAsset() ?>
output
output is relation to the debug level, (*8)
Production Mode:, (*9)
<link rel="stylesheet" href="/dist/default.css"/>
<script src="/dist/main.js"></script>
Development Mode:, (*10)
<link rel="stylesheet" href="/asset/zui/dist/css/zui.css"/>
<link rel="stylesheet" href="/css/view.css"/>
<script src="/asset/jquery/dist/jquery.js"></script>
<script src="/asset/zui/dist/js/zui.js"></script>
<script src="/asset/vue/dist/vue.js"></script>