• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minifier - asset minification and versioning library

#1
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> 
Reply

#2
It looks useful. Thanks!

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

Basic App, an open source simple CMS based on CodeIgniter 4
Reply

#3
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.
Reply

#4
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
Reply

#5
Hi Paul,

You probably need to load a helper in your controller

Code:
helper('minifier');
Reply

#6
yes that works

thanks
Reply

#7
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
Reply

#8
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.
Reply

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

#10
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
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.