Skip to content

Don't want to evaluate @import's for Google fonts #346

@JBCSU

Description

@JBCSU

TL;DR How can I keep less from inlining certain @import's, specifically ones pointing to google fonts?

Details:

I have the following in my .less file:

@import url(//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic|Source+Serif+Pro:400,600,700);

The 1.0.1 version of this package did not resolve this import - it copied it verbatim to the generated .css files. The current version of this plugin goes out and fetches Google's font css at compile time and hardcodes it into my generated .css. This results in several statements of the form

@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 400;
  src: local('Source Sans Pro Regular'), local('SourceSansPro-Regular'), url(http://fonts.gstatic.com/s/sourcesanspro/v11/6xK3dSBYKcSV-LCoeQqfX1RYOo3qOK7g.ttf) format('truetype');
}

My first issue with this is that the font is loaded over http in the generated css. Thus it fails to load on my site, which is served over https. I can fix this by changing the url in the @import statement to https://fontst.googleapis.com/..., but it's annoying to have to specify a protocol.

My second issue is that I'm now hardcoding in my .css stuff that Google might change. I trust them to always serve the correct code via the url they provided me. But they're free to change, for example, the url of their cdn, and then my css would fail to load unless somebody tells me I need to rebuild it.

I tried explicitly settingstrictImports: false in my config, even tho that's supposed to be the default. But my generated .css still has the contents of that url, not the @import statement itself.

How can I keep less from inlining certain @import's, specifically ones pointing to google fonts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions