A
A
Alexey Likhachev2014-08-20 16:30:48
JavaScript
Alexey Likhachev, 2014-08-20 16:30:48

How to build and minify CSS and JS in Yii2?

If I understand correctly, then in yii2 the automatic use of compressed libraries in production is disabled, as it was in yii1, and instead AssetBundle is added, but I don’t quite understand how to use it. It seems that the official documentation has a Compressing and combining assets section , and now minification and assembly are sent to the console. I follow the instructions and don’t understand where the /path/to/myapp/config/assets_compressed.php file comes from and what should be in it. Perhaps someone will poke his nose or tell you in which direction to google.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
Vlad, 2016-06-29
@Allan11

Hey!
ph is the height of the tab block,
parent() - means the parent of the element ( in this case it is )
ch is the height of the content of the selected tab,
next() - means the next element after the current one ( in this case it is )
Then it checks if the height of the content is greater than the height of the tab block, then the height adjusts to the height of the content.

if (ch > ph) {
    $(this).parent().css({
        'min-height': ch + 'px'
    });
}

S
Sergey ZSA, 2016-06-29
@serjikz

jquery.page2page.ru/index.php5/%D0%9F%D0%BE%D0%B8%... Googled
"parent() jQuery" 2 links in the results already. Similarly, search by next and height.

A
Andrew, 2016-06-29
@Menlod

Then, that there is adaptive, and it is necessary to calculate the height of the elements at different resolutions.

P
ph4n70m, 2014-11-19
@Playbot

Understood.
Download from here https://developers.google.com/closure/compiler/ jar and throw
npm i yuicompressor into the root of the project - and drag yuicompressor.jar to the root
too Create a file via ./yii asset/template config/minify.php
Remove comments from two lines at the top (where are the constants) and at the bottom. And also "uncomment"
'bundles' => [
'app\assets\AppAsset',
'yii\web\YiiAsset',
'yii\web\JqueryAsset',
],
and that's it. you can run
./yii asset config/minify.php assets/app_min.php
The output will be a file in assets/app_min.php which you connect to the project

A
Andrey Khromyshev, 2015-02-14
@profak

where exactly to connect?

In the application config file like this
if( ! YII_ENV_TEST) {
    $config['components']['assetManager'] = [
      'bundles' =>require(__DIR__.'/../assets/assets-prod.php'),
    ];
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question