【问题标题】:how to exclude fonts from cassette bundling如何从磁带捆绑中排除字体
【发布时间】:2013-09-13 14:42:25
【问题描述】:

我们正在为我们的 mvc 项目使用盒式磁带捆绑。我们遇到了一个问题,当我们将网站推送到我们的开发服务器时,某些字体文件没有进入cassette.axd。生成的样式表显示了到cassette.axd 中字体文件的链接,但是当我们尝试提取实际的url 时,我们得到一个404。所以我没有包含字体,而是试图看看我们是否可以从cassette 中排除字体文件夹缩小。结构是..

Root
  |Content
    |css
      |styles.css
    |font

styles.css 中包含以下内容...

@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;
}

在从盒式磁带生成的 styles.css 中,对字体的引用类似于...

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

有没有办法可以排除字体文件夹,让css文件中的src继续指向字体文件夹而不是卡带结果?

【问题讨论】:

    标签: cassette


    【解决方案1】:

    找到了答案,至少它为我解决了on Google Groups。将此添加到 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>
    

    【讨论】:

    • 谢谢,这对我也有帮助!
    猜你喜欢
    • 1970-01-01
    • 2019-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    相关资源
    最近更新 更多