0

I have a main.less file. I am running the grunt package: grunt-contrib-less on it to produce css. The generated css file has the following newly inserted at the top (with all other references correctly converted into css):

@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic);

grunt config:

less: {
        dev: {
            src: ['<%= app_files.temp_less %>'],
            dest: '<%= wwwroot_dir %>/assets/<%= pkg.name %>-<%= pkg.version %>.css',
            options: {
                compress: false,
                ieCompat: true,
                dumpLineNumbers: "comments"
            }

This is causing browser errors due to the main page being requested over https yet this making requests over http. Presumably this is happening as the less compilation cant resolve the font? I would like to either include the font so the import statement doesn't appear OR change the URI of the font to: //fonts.googleapis.com.... so that it uses the parents calling method i.e. https. What is the 'correct' way of doing this?

sarin
  • 5,227
  • 3
  • 34
  • 63
  • 1
    Less compiler does not touch this statement at all (and even if it would, it could not change `http` to `https`, because the compiler has no idea how you are going to serve the page you compile your CSS for). Either way if you're serving the page via `https` just change the link to `https` (yes, `fonts.googleapis.com` can serve that too). – seven-phases-max Sep 08 '15 at 14:35
  • Thanks. just realised myself – sarin Sep 08 '15 at 14:38
  • 1
    And yes, actually, of course you was already on the right track. Change it to `//fonts.googleapis.com...` (you just need to do it explicitly yourself) so it could work with either domain. – seven-phases-max Sep 08 '15 at 14:40

1 Answers1

1

i just realized that all the 'compiler' is doing is copying the css from any @import referenced files. In one of these was the above @import statement. I simply found the reference in my project in a less file hidden in a deep dark folder and changed it to //fonts.googleapis.com .... and on compilation this is pulled in instead.

seven-phases-max
  • 11,765
  • 1
  • 45
  • 57
sarin
  • 5,227
  • 3
  • 34
  • 63