webpack - 如何禁用 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
这是我想摆脱的以下请求:
解决方案
我需要完成完全相同的事情。
这个答案帮助了我: Bootstrap CSS without Google Fonts 2 (Bootswatch)
具体来说,我使用了不带 !important 的双引号,并将其设置在我的导入之前:
$web-font-path: "";
@import "~bootswatch/dist/darkly/variables";
@import "~bootstrap/scss/bootstrap";
推荐阅读
- javascript - 使用 shp2stl 的类型错误
- c# - 在 MVC 应用程序中过滤转换为日期 SQL 查询的日期(字符串)
- java - 删除子弹簧靴时删除父母
- python - 更新到 1.2.4 后的 read_csv() pandas
- selenium - Python:相当于firefoxdriver中chromedriver的函数。chromedriver --> firefoxdriver(firefoxdriver 给我语法错误)
- twitter-bootstrap - 如何使用 ttf 文件通过 Bootstrap 5 覆盖现有字体?
- node.js - 如何在本地有 4 个空格缩进?
- google-cloud-functions - Google Cloud Function 在 http 函数调用之间保留数据
- python - 使用 tflite 和 open cv 对汽车进行背光识别
- etcd - etcd v3 中“Watch key changes”的最佳实践