Assets Bundle file and CSS overriding problem

Hi,

I created a new theme.

Views overriding works fine, also the overriding of a new layout file (using pathMap option in the Application Configuration file) but the styling doesn’t work properly.

The CSS file is located at /assets/snow/snow.css

If I put a <h1> tag in an overrided view and in the overrided layout files, it works fine, but If I try to style a <div> and put a <div> there, it doesn’t get styled.

With firebug I found out that the application is searching for the CSS file in /yiiframework/web-project/web/assets/5cd85bb/snow.css while the right path is /assets/snow/snow.css but…<h1> are styled anyway.

These are my AppAsset.php and custom SnowAssetsBundle:

/assets/AppAsset.php:




<?php

/**

 * @link http://www.yiiframework.com/

 * @copyright Copyright (c) 2008 Yii Software LLC

 * @license http://www.yiiframework.com/license/

 */


namespace app\assets;


use yii\web\AssetBundle;


/**

 * @author Qiang Xue <qiang.xue@gmail.com>

 * @since 2.0

 */

class AppAsset extends AssetBundle

{

    public $basePath = '@webroot';

    public $baseUrl = '@web';

    public $css = [

        'css/site.css',

    ];

    public $js = [

    ];

    public $depends = [

        'yii\web\YiiAsset',

        'yii\bootstrap\BootstrapAsset',

    ];

}




/assets/SnowAssetsBundle.php




<?php

/**

 * @copyright lup0z

 */




namespace app\assets;


use yii\web\AssetBundle;


class SnowAssetsBundle extends AssetBundle

{

    public $sourcePath = '@app/assets/snow';

    public $css = [

        'snow.css',

    ];

    public $js = [

    ];

    public $depends = ['app\assets\AppAsset'];

}




Thank you for your help

You probably need to read up on assets, because /yiiframework/web-project/web/assets/5cd85bb/snow.css is the right path.

The assets manager publishes to the ‘assets’ directory, so you should probably treat that as read-only output, and not something to use manually.

See the guide. :)

<edit>

If you don’t want the assets manager to publish your css file, put it in web/css and tell the bundle to not publish.

See the guide for, well, guidance.

Thank you Jacmoe,

I’ll get back with good news after reading it ;)