首页 > 解决方案 > 如何禁用 SCSS 供应商 url 导入?

问题描述

在项目中使用 Webpack 编译模块。其中之一(Bootswatch)覆盖了很多 Bootstrap 来应用主题。

在它的开头_bootswatch.scss有:

$web-font-path: "https://fonts.googleapis.com/css?family=Lato:400,700,400italic" !default;
@import url($web-font-path);

此导入始终运行,导致不需要发生请求(因为字体被覆盖为“Segoe UI”或其他东西,通常已安装且不需要下载。

我怎样才能确保url($...)永远不会完成?

我尝试将其设置为false''""尝试搜索它,但不断获取有关更改它的信息,而不是禁用它。也没有找到如何在文档中禁用它

这些更改是这样完成的:

@import "~bootswatch/dist/darkly/variables";

$web-font-path: '' !important;

这些变化都会导致以下变化:

 WAIT  Compiling...                                                                                                                                                                                                                            2:24:33 PM

 WARNING  Compiled with 1 warnings                                                                                                                                                                                                             2:24:35 PM

 warning  in ./assets/css/admin/admin.scss

Module Warning (from ./node_modules/css-loader/dist/cjs.js):
Warning

(1:1) Unable to find uri in '@import url("" !important)' // insert other tried values here

这是我想摆脱的以下请求:

一些要求

标签: webpacksass

解决方案


我需要完成完全相同的事情。

这个答案帮助了我: Bootstrap CSS without Google Fonts 2 (Bootswatch)

具体来说,我使用了不带 !important 的双引号,并将其设置在我的导入之前:

$web-font-path: "";
@import "~bootswatch/dist/darkly/variables";
@import "~bootstrap/scss/bootstrap";

推荐阅读