-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added command minify-js and minify-css
- Loading branch information
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of PHPDevsr/Minifyku. | ||
* | ||
* (c) 2023 Denny Septian Panggabean <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPDevsr\Minifyku\Commands; | ||
|
||
use CodeIgniter\CLI\BaseCommand; | ||
use CodeIgniter\CLI\CLI; | ||
use CodeIgniter\Config\Services; | ||
|
||
/** | ||
* Minify CSS assets | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
class MinifyCss extends BaseCommand | ||
{ | ||
protected $group = 'Minifyku'; | ||
protected $name = 'minifyku:minify-css'; | ||
protected $description = 'Minify all assets CSS.'; | ||
|
||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Prepare assets to use on website | ||
*/ | ||
public function run(array $params) | ||
{ | ||
$benchmark = Services::timer(); | ||
$minify = service('minifyku'); | ||
|
||
$benchmark->start('Minifyku'); | ||
|
||
$result = $minify->deploy('css'); | ||
|
||
$benchmark->stop('Minifyku'); | ||
|
||
if (! $result) { | ||
CLI::error($minify->getError()); | ||
|
||
exit; | ||
} | ||
|
||
$time = $benchmark->getElapsedTime('Minifyku'); | ||
|
||
CLI::write('[+] Finished in: ' . CLI::color($time . 's.', 'green')); | ||
CLI::write('[+] All files CSS were successfully generated.', 'green'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of PHPDevsr/Minifyku. | ||
* | ||
* (c) 2023 Denny Septian Panggabean <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPDevsr\Minifyku\Commands; | ||
|
||
use CodeIgniter\CLI\BaseCommand; | ||
use CodeIgniter\CLI\CLI; | ||
use CodeIgniter\Config\Services; | ||
|
||
/** | ||
* Minify JS assets | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
class MinifyJs extends BaseCommand | ||
{ | ||
protected $group = 'Minifyku'; | ||
protected $name = 'minifyku:minify-js'; | ||
protected $description = 'Minify all assets JS.'; | ||
|
||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Prepare assets to use on website | ||
*/ | ||
public function run(array $params) | ||
{ | ||
$benchmark = Services::timer(); | ||
$minify = service('minifyku'); | ||
|
||
$benchmark->start('Minifyku'); | ||
|
||
$result = $minify->deploy('js'); | ||
|
||
$benchmark->stop('Minifyku'); | ||
|
||
if (! $result) { | ||
CLI::error($minify->getError()); | ||
|
||
exit; | ||
} | ||
|
||
$time = $benchmark->getElapsedTime('Minifyku'); | ||
|
||
CLI::write('[+] Finished in: ' . CLI::color($time . 's.', 'green')); | ||
CLI::write('[+] All files JS were successfully generated.', 'green'); | ||
} | ||
} |