Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to exclude fonts from cassette bundling

Tags:

cassette

We're using cassette bundling for our mvc project. We ran into an issue that when we push our site to our dev server, certain font files aren't making their way into cassette.axd. The resulting stylesheet shows a link to the font file in cassette.axd but when trying to pull up the actual url we get a 404. So rather than having the fonts included I'm trying to see if we can exclude the font folder from cassette's minification. The structure is..

Root
  |Content
    |css
      |styles.css
    |font

The styles.css has the following in it...

@font-face {
    font-family: 'latolight_italic';
    src: url('../font/lato-lightitalic-webfont.eot');
    src: url('../font/lato-lightitalic-webfont.eot?#iefix') format('embedded-opentype'),
         url('../font/lato-lightitalic-webfont.woff') format('woff'),
         url('../font/lato-lightitalic-webfont.ttf') format('truetype'),
         url('../font/lato-lightitalic-webfont.svg#latolight_italic') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'latoregular';
    src: url('../font/lato-regular-webfont.eot');
    src: url('../font/lato-regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('../font/lato-regular-webfont.woff') format('woff'),
         url('../font/lato-regular-webfont.ttf') format('truetype'),
         url('../font/lato-regular-webfont.svg#latoregular') format('svg');
    font-weight: normal;
    font-style: normal;
}

In the resulting styles.css from cassette the references to the fonts are something like...

src: url('/newdesign/cassette.axd/file/Content/font/lato-regular-webfont-5daaab4d79c85c0ac9f932c4848f08f673f3e6c4.eot'

Is there a way that we can exclude the font folder so that the src in the css file continues to point to the font folder instead of the cassette result?

like image 414
geoff swartz Avatar asked Oct 22 '22 01:10

geoff swartz


1 Answers

Found the answer, at least it solved it for me on Google Groups. Add this to in Web.config:

<staticContent>
    <remove fileExtension=".eot" />
    <remove fileExtension=".otf" />
    <remove fileExtension=".svg" />
    <remove fileExtension=".ttf" />
    <remove fileExtension=".woff" />

    <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
    <mimeMap fileExtension=".otf" mimeType="application/x-font-opentype" />
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    <mimeMap fileExtension=".ttf" mimeType="application/x-font-truetype" />
    <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
like image 80
Greg R Avatar answered Oct 25 '22 17:10

Greg R