Team yii asset/template in YII?

Trying to tame JquerySparkline. The problem is that on the issue tracker in native repositories no pre-assembled sparkline-js file (strange, but the author believes that it is better and publishes only the individual modules that everyone should gather under a well, or all together).
Write the resource file for the Sparkline
common/assets/sparkline/Gwatts_JquerySparklineAsset_combine.php
:
class Gwatts_JquerySparklineAsset_combine extends AssetBundle
{
 public $sourcePath = '@vendor/gwatts/jquery.they/src';
 public $js = [
'header.js',
'defaults.js',
'utils.js',
'simpledraw.js',
'rangemap.js',
'interact.js',
'base.js',
'chart-line.js',
'chart-bar.js',
'chart-tristate.js',
'chart-discrete.js',
'chart-bullet.js',
'chart-pie.js',
'chart-box.js',
'vcanvas-base.js',
'vcanvas-canvas.js',
'vcanvas-vml.js',
'footer.js',
];
 }

Will notice right away that it won't work, because js pieces in reality - unrelated pieces and the browser don't eat them. Well that YII provides a packet assembler. Go to the console, write
yii asset/template common/assets/sparkline/Gwatts_JquerySparklineAsset_config.php
file is created, go into it and configure:
// I don't want to immediately publish the collected file on prod and want to keep it inside the project, then to connect the two subdomains of
// file will be placed in the folder common/assets/sparkline/sparkline.js
Yii::setAlias('@webroot', __DIR__.'/sparkline');
Yii::setAlias('@web', '/');

return [
 // Adjust command/callback for JavaScript files compressing:
 'jsCompressor' => 'java-jar compiler.jar --js {from} --js_output_file {to}',
 // Adjust command/callback for CSS files compressing:
 'cssCompressor' => 'java-jar yuicompressor.jar --type css {from} -o {to}',
 // The list of asset bundles to compress:
 'bundles' => [
 // this file contains a list of those js pieces of code that you want to collect
 // description of it below
common\assets\Gwatts_JquerySparklineAsset_combine::className(),
],
 // Asset bundle for compression output:
 'targets' => [
 'Gwatts_JquerySparklineAsset' => [
 'class' => common\assets\Gwatts_JquerySparklineAsset_combine::className(),
 'basePath' => '@webroot',
 'baseUrl' => '@web',
 'js' => 'sparkline.js',
],
],
 // Asset manager configuration:
 'assetManager' => [
 'basePath' => '@webroot',
 'baseUrl' => '@web',
],
 ];

Start
yii asset/compress common/assets/sparkline/Gwatts_JquerySparklineAsset_config.php common/assets/sparkline/Gwatts_JquerySparklineAsset_bundle.php
. As a result, in the folder common/assets/sparkline finds a folder 3c99cc05 with all our js and pieces file sparkline.js. It also creates a file Gwatts_JquerySparklineAsset_bundle.php with the following content:
return [
 'Gwatts_JquerySparklineAsset' => [
 'class' => 'common\\assets\\Gwatts_JquerySparklineAsset_combine',
 'basePath' => '@webroot',
 'baseUrl' => '@web',
 'js' => [
'sparkline.js',
],
 'css' => [],
],
 'common\\assets\\Gwatts_JquerySparklineAsset_combine' => [
 'sourcePath' => null,
 'js' => [],
 'css' => [],
 'depends' => [
'Gwatts_JquerySparklineAsset',
],
],
];

We, in fact, it is not needed. Again - I just needed to collect they in a single file, so create another resource file Gwatts_JquerySparklineAsset:
class Gwatts_JquerySparklineAsset extends AssetBundle
{
 public $sourcePath = '@common/assets/sparkline';
 public $js = [
'sparkline.js',
];
 }

Here it is and you can cling to project anywhere.

Now the questions:
1. Is it possible to somehow simplify the whole thing?
2. Do I have to create so many files?
July 9th 19 at 10:06
1 answer
July 9th 19 at 10:08
Read the question? - grady.Nad commented on July 9th 19 at 10:11
Yes. The answer is dismantled? - Henderson_Beat commented on July 9th 19 at 10:14

Find more questions by tags Yii