CodeIgniter Forums
Minifier - asset minification and versioning library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34)
+--- Thread: Minifier - asset minification and versioning library (/showthread.php?tid=75965)

Pages: 1 2


Minifier - asset minification and versioning library - michalsn - 04-02-2020

https://github.com/michalsn/minifier

Installation:

Code:
composer require michalsn/minifier


Configuration:

PHP Code:
public $js = [
    
'all.min.js' => [
        
'jquery-3.2.1.min.js''bootstrap-3.3.7.min.js''main.js',
    ]
]; 
Code:
php spark minify:js


Usage:

PHP Code:
<?= minifier('all.min.js'); ?>
// will produce
// <script type="text/javascript" src="http://localhost/assets/js/all.min.js?v=9ef881911da8d7c4a1c2f19c4878d122"></script> 



RE: Minifier - asset minification and versioning library - Basic App - 04-03-2020

It looks useful. Thanks!

In what file do I need to write "public $js = [...]"?


RE: Minifier - asset minification and versioning library - michalsn - 04-03-2020

It's in the "Config/Minifier.php" file. You can run command:
Code:
php spark minify:publish

to copy the default config file to your application and then modify it to your needs.


RE: Minifier - asset minification and versioning library - paul - 04-13-2020

hello

i tried this library

and used the installation via composer

but the function Minifier() is not found

"Call to undefined function Minifier()"

do you know how to fix it

thx


RE: Minifier - asset minification and versioning library - michalsn - 04-13-2020

Hi Paul,

You probably need to load a helper in your controller

Code:
helper('minifier');



RE: Minifier - asset minification and versioning library - paul - 04-13-2020

yes that works

thanks


RE: Minifier - asset minification and versioning library - paul - 04-14-2020

this package is good but maybe the Dir config will be upgrade

for me the URL to css is css.mydomaine.com/mycss.css and the dir to css file in php is ../system/assets/css/mycss.css

i think the four parameters $baseUrl, $dirJs, $dirCss, $dirVersion would be changed by $UrlJS, $UrlCss, $dirJs, $dirCss, $dirVersion

what do you think of that


RE: Minifier - asset minification and versioning library - michalsn - 04-14-2020

Well, yes... separate URL config like $cssUrl and $jsUrl might be a good addition if someone would like to serve these files from a separate domain.

Thanks for the idea.


RE: Minifier - asset minification and versioning library - paul - 04-14-2020

yes and i think it's useful if the public directory is not at the same level of the assets directory


RE: Minifier - asset minification and versioning library - paul - 04-15-2020

I tried used this package in manual installation mode and all the command php spark minify:* are not found

do you know how to fix it