Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAssetBundle is linking scss files in the HTML head #17994
Labels
Comments
|
Would you please put together a simple test case to reproduce it starting with basic app template and making minimal amount of changes? Thanks. |
|
Frontend App Advanced main config: <?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
);
$from = dirname(__DIR__) . '/themes/grayscale/scss/grayscale.scss';
$to = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT') . "/web/themes/grayscale/css/grayscale.css";
return [
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'assetManager' => [
'bundles' => [
#'yii\web\JqueryAsset' => [
# 'sourcePath' => null, 'js' => [],
#],
'yii\bootstrap\BootstrapAsset' => [
'sourcePath' => null, 'css' => [],
],
'yii\bootstrap\BootstrapPluginAsset' => [
'sourcePath' => null, 'js' => [],
],
'yii\jui\JuiAsset' => [
'sourcePath' => null, 'css' => [], 'js' => [],
],
'\rmrevin\yii\fontawesome\AssetBundle' => [
'sourcePath' => null, 'css' => [],
],
],
'converter' => [
'class' => 'yii\web\AssetConverter',
'commands' => [
'scss' => ['scss', "sass $from $to --source-map"]
],
'forceConvert' => true
],
'appendTimestamp' => true,
],
'view' => [
'theme' => [
#'class' => yii\base\Theme::class,
'basePath' => '@app/themes/grayscale',
'pathMap' => ['@app/views' => '@app/themes/grayscale'],
'baseUrl' => '@web/themes/grayscale',
]
],
'request' => [
'csrfParam' => '_csrf-frontend',
'baseUrl' => '/web',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the frontend
'name' => 'advanced-frontend',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
[
'class' => yii\log\SyslogTarget::class,
'levels' => ['error', 'warning']
]
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
#'suffix' => '.html',
'rules' => [
// tecnorecicla
'requirement/<action:\w+>' => '/web/requirement/<action>',
],
],
],
'params' => $params,
];Frontend App Asset: <?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace frontend\assets;
use Yii;
use yii\web\AssetBundle;
use yii\helpers\FileHelper;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class ThemeAsset extends AssetBundle
{
/**
* {@inheritdoc}
*/
public $sourcePath = '@app/themes/grayscale'; //maybe set also as maybe unset
/**
* {@inheritdoc}
*/
public $basePath = "@webroot/themes/grayscale";
/**
* {@inheritdoc}
*/
public $baseUrl = '@web/themes/grayscale';
/**
* {@inheritdoc}
*/
public $css = [
'vendor/bootstrap/css/bootstrap.min.css',
'vendor/fontawesome-free/css/all.min.css',
"scss/grayscale.scss", // this is the scss inside @frontend/themes/grayscale/scss. This is rendered as <link href="/web/themes/grayscale/scss/grayscale.scss" rel="stylesheet">
'css/grayscale.css', // this is the compiled scss inside @webroot/themes/grayscale/css
[
'href' => "favicon.ico",
'rel' => 'icon',
'sizes' => '16x16',
],
];
/**
* {@inheritdoc}
*/
public $js = [
#'vendor/jquery/jquery.min.js',
'vendor/bootstrap/js/bootstrap.bundle.min.js',
'js/grayscale.min.js',
"vendor/jquery-easing/jquery.easing.min.js"
];
/**
* {@inheritdoc}
*/
public $depends = [
'yii\web\YiiAsset',
#'yii\bootstrap\BootstrapAsset',
#'yii\bootstrap\BootstrapPluginAsset',
];
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Additional info
I'm following this guide to convert scss files to css files.
In the css array from my AppAsset I have to add
scss/myFile.scssto yii runs the converter command, but with this, the AssetBundle renders into the HTML head section the link to the scss file, so I have to add into the same array, the css filecss/myFile.css.