Answer the question
In order to leave comments, you need to log in
How to set addresses to resources in css when using resource compression in Yii2?
Good day.
Compressing resources, using the method described by
https://github.com/yiisoft/yii2/blob/master/docs/g...
Faced a problem.
For example, the project has a single bundle Test
class TestAsset extends AssetBundle
{
public $sourcePath = '@app/assets-resources/test';
public $css = [
'1.css'
];
public $js = [
];
public $depends = [
];
}
@font-face {
font-family: 'Glyphicons Halflings';
src: url('glyphicons-halflings-regular.eot');
}
Yii::setAlias('@webroot', '../www');
Yii::setAlias('@web', '/');
return [
// Adjust command/callback for JavaScript files compressing:
'jsCompressor' => 'java -jar compiler.jar --js {from} --js_output_file {to}',
// Adjust command/callback for CSS files compressing:
'cssCompressor' => 'java -jar yuicompressor.jar --type css {from} -o {to}',
// The list of asset bundles to compress:
'bundles' => [
'app\assets\TestAsset',
],
// Asset bundle for compression output:
'targets' => [
'all' => [
'class' => 'yii\web\AssetBundle',
'sourcePath' => null,
'basePath' => '@webroot/assets',
'baseUrl' => '@web/assets',
// 'js' => 'all-{hash}.js',
'css' => 'all-{hash}.css',
],
],
// Asset manager configuration:
'assetManager' => [
'basePath' => '@webroot/assets',
'baseUrl' => '@web/assets',
],
];
@font-face{font-family:'Glyphicons Halflings';src:url('../../C:/Dropbox/_htdocs/site/www/assets/43e204a5/glyphicons-halflings-regular.eot')}a{color:#333}
Answer the question
In order to leave comments, you need to log in
After a long night, the problem was almost solved.
In the configuration for the minimizer, I set alias webroot as
yii
\console\controllers\AssetController when setting a relative address ('@webroot', '../www' ) it cannot "cut" the relative address from css files, because to. in css they are set absolutely, and in elias relatively
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question