Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for Absolute paths on Assets #6

Open
dbd5 opened this issue May 30, 2016 · 4 comments
Open

No support for Absolute paths on Assets #6

dbd5 opened this issue May 30, 2016 · 4 comments

Comments

@dbd5
Copy link

dbd5 commented May 30, 2016

Hi,

It appears that the extension assumes that all URLs are relative when combining the minified assets so references to all resources with absolute paths become unreachable after '../../' is appended to them with the result that all such assets are no longer reachable (Icon files, Images - everything with absolute URL etc). See the following extract from the combined resource files showing the effect on font awesome;

@font-face{font-family:'FontAwesome';src:url**('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.eot?v=4.3.0')**;src:url**('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0')** format('embedded-opentype'),url**('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.woff2?v=4.3.0')** format('woff2'),url**('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.woff?v=4.3.0')** format('woff'),url**('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.ttf?v=4.3.0')** format('truetype'),url**('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular')**

Thanks

@moltam
Copy link
Contributor

moltam commented May 31, 2016

I can't reproduce this.

Can you share more details?

  • The path of the css file,
  • The original font-face declaration in the css file,
  • The AssetBundle,
  • Your asset-minifier extension config.

@dbd5
Copy link
Author

dbd5 commented May 31, 2016

Hi @moltam ,

I have provided all responses below as well as additional relevant config to clarify;

//----Path of CSS file
/advanced/frontend/web/assets/css

//----Path of FontAwesome files
/advanced/frontend/web/assets/css/fonts

//----Declaration of FontAwesome in font-awesome.css (Standard for FontAwesome 4.3.0)
@font-face{font-family:'FontAwesome';src:url('fonts/fontawesome-webfont.eot?v=4.3.0');src:url('fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');
...

//----Relevant setting in /config/bootstrap.php
Yii::setAlias('@home_url', 'http://advanced.rev');

//----Listing of relevant Asset bundle - FrontendAsset.php

\yii\web\View::POS_HEAD, ]; ``` public $css = [ 'css/font-awesome.css', 'css/line-icons.min.css', 'css/animations.min.css', 'css/bootstrap.min.css', 'css/google-fonts.min.css', 'css/bootstrap-theme.min.css', 'css/style.min.css', 'css/colors/color6.min.css', 'css/custom.css', ]; public $js = [ 'js/plugins.js', 'js/modernizr.js', ]; public $images = [ ]; public $depends = [ 'yii\web\YiiAsset', 'yii\web\JqueryAsset', 'common\assets\Html5shiv', ]; ``` } **//----Extract from Homepage - View source** ... ![image](https://cloud.githubusercontent.com/assets/9496750/15685055/ee93fbf2-2761-11e6-85bf-1e93ca86b269.png) **//----Extract from Combined CSS files** **\* BEGIN FILE: font-awesome.min.css ***/ @font-face{font-family:'FontAwesome';src:url('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('../../http://advanced.rev/assets/css/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') **//----Asset Minifier Config** ... 'assetMinifier' => [ 'class' => \lajax\assetminifier\Component::className(), 'minifyJs' => true, // minify js files. [default] 'minifyCss' => true, // minify css files [default] 'combine' => false, // combine asset files. [default] 'createGz' => false, // create compressed .gz file, (so the web server doesn’t need to // compress asset files on each page view). Requires // special web server configuration. [default] 'minifier' => [ // Settings of the components performing the minification of asset files 'workPath' => lajax\assetminifier\Minifier::WORKPATH_SOURCE, // default setting 'js' => [ // Default JS minifier. 'class' => 'lajax\assetminifier\minifiers\PhpJsMinifier', // default settings, you can override them 'options' => [ 'flaggedComments' => true // Disable YUI style comment preservation. ] ], 'css' => [ // Default CSS minifier. 'class' => 'lajax\assetminifier\minifiers\PhpCssMinifier', // default settings, you can override them 'filters' => [ 'ImportImports' => false, 'RemoveComments' => true, 'RemoveEmptyRulesets' => true, 'RemoveEmptyAtBlocks' => true, 'ConvertLevel3AtKeyframes' => false, 'ConvertLevel3Properties' => false, 'Variables' => true, 'RemoveLastDelarationSemiColon' => true ], 'plugins' => [ 'Variables' => true, 'ConvertFontWeight' => true, 'ConvertHslColors' => true, 'ConvertRgbColors' => true, 'ConvertNamedColors' => true, 'CompressColorValues' => true, 'CompressExpressionValues' => true, ] ] ], 'combiner' => [ 'class' => 'lajax\assetminifier\Combiner', 'combinedFilesPath' => '/lajax-asset-minifier' ] ], ...

@moltam
Copy link
Contributor

moltam commented Jun 1, 2016

Thank you for your reply. I've managed to reproduce this. This is caused by the absolute url in the baseUrl (public $baseUrl = '@home_url/assets';).

You can use with relative url-s for now. The default @web/assets should work fine. I don't know when can we look at this.

@dbd5
Copy link
Author

dbd5 commented Jun 1, 2016

Hi @moltam ,

Thanks for your support - and if there is anything I can do to help, just let me know

Regards,

Adam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants