How to use the google font v2 API import url in sass file with webpack laravel mix?

时光总嘲笑我的痴心妄想 提交于 2021-02-10 15:40:19

问题


I'm trying to import a google font into my a sass file, right at the top before all other styles.

I am using webpack laravel mix, and I am also using the google font v2 API link.

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@500;600;700;800;900&display=swap");

The problem with the new css2 link, it contains semi-colons and creates css parse errors.

The sass file actually compiles fine, but this is the output of the css file...

@import url(https://fonts.googleapis.com/css2?family=Inter:wght@500;

600;700;800;900&display=swap);@charset "UTF-8";

Which is not valid, and the main fonts do not work, only the fallback font san-serif works.


The only way I've found to temporarily get round this problem is to use the old url. But I would rather use the latest google v2 url.

@import url("https://fonts.googleapis.com/css?family=Inter:500,600,700,800,900");

来源:https://stackoverflow.com/questions/63505687/how-to-use-the-google-font-v2-api-import-url-in-sass-file-with-webpack-laravel-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!