A
A
Alex Shalin2014-10-18 04:37:36
Yii
Alex Shalin, 2014-10-18 04:37:36

How to build Yii1+Grunt+Less/JS+Packages work?

Hello!
There is a project on Yii1. Different pages and modules (backend/frontend) require certain js plugins and css files. Everything is organized through packages like this:

// main.php
'clientScript'=>array(
  'packages'=>путь_до_файла,
)
// —————————————— //

// package.php
$path = 'application.src';
return array(
  'jquery'=>array(
    'basePath'=>$path,
    'js'=>array('js/vendors/jquery.min.js'),
  ),
  'slider' => array(
    'basePath'=>$path,
    'js'=>array('js/vendors/jquery.jcarousel.min.js','js/slider.js'),
    'depends' => array('jquery'),
    ),
  'backend' => array(
    'baseUrl'=>$path,
    'js'=>array('js/scripts.js'),
    'css'=>array('css/s-3.0.0.css'),
    'depends' => array('jquery'),
    ),
  'frontend' => array(
    'basePath'=>$path,
    'js'=>array('js/vendors/modernizr-2.6.2.min.js','js/vendors/jquery.scrollto-1.4.3.1-min.js','js/scripts.js'),
    'css'=>array('css/build.css'),
    'depends' => array('jquery'),
    ),

// где нужно, регистрирую пакет и понеслась
Yii::app()->clientScript->registerPackage('slider');

);

I study the grant and have questions:
1. The grant allows you to collect all js libraries into one and connect it to the frontend once. But what about other site modules that may require completely different js? To score and connect everything everywhere (bumping into conflicts) or describe it in a grant file? (I would like a more universal solution for the following projects).
2. In addition to js, ​​many plugins have their own styles, pictures, how to deal with this, describe the path thoroughly in the grant file?
3. Where do you set up folding the final files, considering assetmanager yii? For example, in this question I found the answer.
I would be grateful for the best best practices.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-10-18
Protko @Fesor

it is better to collect gulp. And yes, Yii's assetManager is useless. At all. bower + gulp.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question