webpack - 为什么 less-loader 不起作用 TypeError: this.getOptions is not a function
问题描述
我有一个 react+typescript 项目。我遇到了这个问题,less-loader 不能工作。我在 stackoverflow 中找到了答案,安装 less-loader@5.0.0 但它不起作用。
这是我的配置 webpack
{
test: lessRegex,
exclude: lessModuleRegex,
use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
},
'less-loader'
),
// Don't consider CSS imports dead code even if the
// containing package claims to have no side effects.
// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issues/6571
sideEffects: true,
},
// Adds support for CSS Modules, but using SASS
// using the extension .module.scss or .module.sass
{
test: lessModuleRegex,
use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
modules: true,
getLocalIdent: getCSSModuleLocalIdent,
},
'less-loader'
),
},
包.json
"webpack": "4.44.2",
"less": "^4.1.2",
"less-loader": "^5.0.0",
有人可以帮我吗?请。
解决方案
推荐阅读
- javascript - 2个数组匹配,对象数组的转换
- visual-studio-code - 如何将 TextMate 语法注入 VS Code 中的 Markdown 标题?
- reactjs - 在“normalizr”中找不到架构
- swift - 以编程方式从 UITabBarController 正确导航到 UIViewController (Swift - UIKit),反之亦然
- mysql - 我想知道是否可以使用用户定义的 mysql 函数对 @ColumntTansformer 进行数据加密,而无需对密钥进行硬编码
- julia - 在 Julia 中合并子图
- testing - 哪些工具可用于具有查询相关响应和基于 ci 的本地/本地测试的 openapi v3 模拟?
- spring-security - spring-security-core-2.0-RC5 不显示登录视图
- multithreading - 并发查询和插入在带有objectbox的android中有什么副作用吗?
- android - 隐藏在选项卡布局后面的 TextView