Hi, if you want to use webpack with ManifestPlugin : \Library\Assets.php
<?php
/**
* Created by PhpStorm.
* User: pedrocosta
* Date: 2019-03-27
* Time: 10:27
*/
namespace Library;
use Phalcon\Assets\Manager;
class Assets extends Manager
{
protected $_map = [];
public function addCss(string $path, $local = NULL, $filter = NULL, $attributes = NULL): Manager {
return parent::addCss($this->transformName($path), $local, $filter, $attributes);
}
public function addJs(string $path, $local = NULL, $filter = NULL, $attributes = NULL): Manager{
return parent::addJs($this->transformName($path), $local, $filter, $attributes);
}
public function setNamesMap(array $map){
$this->_map = $map;
}
public function transformName($name){
return isset($this->_map[$name]) ? $this->_map[$name] : $name;
}
public function collection(string $name): \Phalcon\Assets\Collection{
if(isset($this->collections[$name]))
return $this->collections[$name];
return $this->collections[$name] = new Collection($name);
}
}
\Library\Assets\Collection.php
<?php
namespace Library\Assets;
use Library\Assets;
use Phalcon\Assets\Manager;
class Collection extends \Phalcon\Assets\Collection{
public function addCss(string $path, $local = NULL, $filter = TRUE, $attributes = NULL): \Phalcon\Assets\Collection {
return parent::addCss(Assets::transformName($path), $local, $filter, $attributes);
}
public function addJs(string $path, $local = NULL, $filter = TRUE, $attributes = NULL): \Phalcon\Assets\Collection{
return parent::addJs(Assets::transformName($path), $local, $filter, $attributes);
}
}
in your services.php
use Library\Assets;
$di->setShared('assets', function () use ($di){
$assets = new Assets();
if(file_exists('path/to/assetsMap.json')){
$di->get("assets")->setNamesMap(json_decode(file_get_contents('path/to/assetsMap.json'), true));
}
return $assets;
});