I have bundled plugins css file as
StyleBundle adminArea = new StyleBundle("~/files/css/admin/common");
adminArea.Include("~/assets/global/plugins/font-awesome/css/font-awesome.css");
as font awesome uses its font which is located in its directory I copied its fonts located in that plugin directory to fonts folder in root level and changed the location in css file as
@font-face {
font-family: 'FontAwesome';
src: url('/fonts/fontawesome-webfont.eot?v=4.4.0');
src: url('/fonts/fontawesome-webfont.eot?#iefix&v=4.4.0') format('embedded-opentype'),
url('/fonts/fontawesome-webfont.woff2?v=4.4.0') format('woff2'),
url('/fonts/fontawesome-webfont.woff?v=4.4.0') format('woff'),
url('/fonts/fontawesome-webfont.ttf?v=4.4.0') format('truetype'),
url('/fonts/fontawesome-webfont.svg?v=4.4.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
When this bundle is requested the font awesome css file point font using relative path as font face source url is change to ../fonts/*.eot?v=4.4.0
@font-face{
font-family:'FontAwesome';
src:url('../fonts/fontawesome-webfont.eot?v=4.4.0');
src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.4.0') format('embedded-opentype'),
url('../fonts/fontawesome-webfont.woff2?v=4.4.0') format('woff2'),
url('../fonts/fontawesome-webfont.woff?v=4.4.0') format('woff'),
url('../fonts/fontawesome-webfont.ttf?v=4.4.0') format('truetype'),
url('../fonts/fontawesome-webfont.svg?v=4.4.0#fontawesomeregular') format('svg');
font-weight:normal;
font-style:normal
}
Which makes request goes to virtual path created for bundle where font are not placed.
My confusion is why bundling changed font absolute path to relative path. How can I solve this without creating folder structure as I created for bundle? MVC Version 5 .NET Framework : 4.5
Note
- I have changed font url only in unminified version of css minified version is not touched in any way.
- I have also enabled optimization in bundle.