A
A
AUN2016-01-28 21:55:32
Yii
AUN, 2016-01-28 21:55:32

Yii2. How to minimize and merge files?

Hey!
The task of minimizing and gluing css, js arose. I wrote my own component responsible for minimizing and merging files. We got 2 files all=1453985904.js and all-1453985904.css, which must be included in your AssetBundle.
How can I do that? Naturally, timestamps like 1453985904 will sometimes change.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rikcon, 2016-01-28
@Rikcon

Minimization and gluing, as it were, should be done by Gulp or Grunt even before everything goes into production.
Here is 1 link from Google if you really want yii to do this.
yiiframework.ru/forum/viewtopic.php?t=19411

V
v0lume, 2016-01-29
@v0lume

if you stop at your minification approach, you can substitute a file for AssetBundle on the fly by overriding init():

public function init()
    {
        parent::init();

        $js = $this->js;
        $js[] = 'js/cart.'.Yii::$app->language.'.js';
        $this->js = $js;
    }

G
Grigory Vasilkov, 2016-01-29
@gzhegow

I have code ready to do this for you.
write to viber

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question