Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assets bundles in yii2 generate empty files

Tags:

php

yii2

Asset bundle generate empty JavaScript and CSS files

namespace frontend\assets;

return [

    'bundles' => [
        'frontend\assets\AppAsset',

    ],

    'targets' => [
        'frontend\assets\AppAsset' => [
            'basePath' => 'e:/path/yii2.loc/www',
            'baseUrl' => '',
            'js' => 'js/{ts}.js',
            'css' => 'css/{ts}.css',
        ],
    ],

    'assetManager' => [
        'basePath' => 'e:/path/yii2.loc/www/assets',
        'baseUrl' => '',
    ],
];

config.php

return [

    'bundles' => [
        'frontend\assets\AppAsset',
    ],

    'targets' => [
        'frontend\assets\AppAsset' => [
            'basePath' => 'e:/path/yii2.loc/www',
            'baseUrl' => '',
            'js' => 'cache/{ts}.js',
            'css' => 'cache/{ts}.css',
        ],
    ],

    'assetManager' => [
        'basePath' => 'e:/path/yii2.loc/www/assets',
        'baseUrl' => '',
    ],
];

Then in console

yii asset e:\path\config.php e:\path\compressed.php
//compresed.php it's result file with name of compressed files

And in config

'assetManager' => [
    'bundles' => require dirname(__DIR__) . '/assets/compressed.php',
],

CSS and JavaScript files are in a directory:

e:/path/yii2.loc/www/css

And

e:/path/yii2.loc/www/js

Bundle generate empties to:

e:/path/yii2.loc/www/cache/css and e:/path/yii2.loc/www/cache/js

What did I do wrong?

like image 718
Vitaliy Avatar asked Feb 14 '14 14:02

Vitaliy


1 Answers

Inside your config.php, try to config component 'assetManager' like as the following LOCs:

'components' => [
    'assetManager' => [
        'class' => 'yii\web\AssetManager', 
        'basePath' => 'YOUR_BASE_PATH' 
    ],  
],
like image 132
Nguyen Duy Phong Avatar answered Nov 01 '22 04:11

Nguyen Duy Phong