Answer the question
In order to leave comments, you need to log in
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');
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question