Minifyku is helper versioning and minification your assets with Codeigniter 4, Can be automatically use base_url()
.
install with composer
$ composer require phpdevsr/minifyku
$ php spark minifyku:publish
This command will copy a config file to your app namespace. Then you can adjust it to your needs. By default, file will be present in app/Config/Minifyku.php
.
public array $js = [
'all.min.js' => [
'bootstrap.js', 'jquery.js', 'main.js'
],
];
public array $css = [
'all.min.css' => [
'bootstrap.css', 'font-awesome.css', 'main.css'
],
];
This configuration will be minify and combine file bootstrap.js
,jquery.js
,main.js
to all.min.js
. Or minify and combine file bootstrap.css
,font-awesome.css
,main.css
to all.min.css
.
Since v2.0.0
, new option autoMinify
for you need automated minify when loaded using helper minifyku()
and can be replaced by .env
with minifyku.autoMinify = true
. Please dont use in production, it will take more time.
public bool $autoMinify = false;
Run command for minification your all assets:
$ php spark minifyku:minify
or you want minify JS/CSS files:
$ php spark minifyku:minify-js
$ php spark minifyku:minify-css
This will prepare everything and will set up a versioning. Make sure to load a minifier helper in your controller, by calling:
helper('minifyku');
Now to generate a proper tag with desired file to load, you have to make a simple call in your code:
minifyku('all.min.js');
or
minifyku('all.min.css');
Helper will be produce:
<script defer type="text/javascript" src="http://example.com/assets/js/all.min.js?v=bc3d0dc779f1a0b521b69ed3a2b85de8"></script>
or
<link rel="stylesheet" href="http://localhost/assets/css/all.min.css?v=ec8d57dd8de143d7ef822a90fca20957">
This project is licensed under the MIT License - see the LICENSE file for details.
We does accept and encourage contributions from the community in any shape. It doesn't matter whether you can code, write documentation, or help find bugs, all contributions are welcome.
Made with contrib.rocks.