javascript - ValidationError:无效的选项对象。CSS Loader 已使用与 API 架构不匹配的选项对象进行初始化
问题描述
我正在使用@zeit/next-css
将 css 文件导入到我的组件和页面文件中,但它向我抛出了这个错误
./styles/navbar.css
在我的组件中导入这个 css 文件,我navbar.js
收到了这个错误
ValidationError: Invalid options object. CSS Loader has been initialised using
an options object that does not match the API schema.
- options has an unknown property 'minimize'. These properties are valid:
object { url?, import?, modules?, sourceMap?, importLoaders?, localsConvention?, onlyLocals? }
我next.config.js
的放置在package.json
哪里
const withCSS = require("@zeit/next-css");
module.exports = withCSS();
我的包 json
{
"name": "transfer-to",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@zeit/next-css": "^1.0.1",
"isomorphic-unfetch": "^3.0.0",
"next": "9.0.7",
"react": "16.10.2",
"react-dom": "16.10.2"
}
}
解决方案
更新 css-loader 后我遇到了同样的问题,但我解决了。
如果您检查 css-loader 自述文件,那么我注意到“localIdentName”已移入模块键(可能不是最近的更改,只是我的工件是旧的)。我当前的工作配置是:
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
modules: true,
modules : {
localIdentName: '[name]__[local]__[hash:base64:5]',
},
},
},
旧的错误配置是:
{
loader: "css-loader",
options: {
modules: true,
localIdentName: "[name]__[local]___[hash:base64:5]",
sourceMap: isDevelopment
}
}
推荐阅读
- pandas - Pandas 中日期时间的 Groupby Year 和 Month
- javascript - 刷新 MEN 堆栈网页而不刷新整个页面
- javascript - Java aes加密代码,如何通过nodejs实现?
- html - 在 HTML 文本框中上传文件选项/图标
- excel - 使用目标格式将范围从工作表复制到另一个工作表?
- excel - 如何使用 Excel Interop (VB.net) 获取 CustomDocumentProperties?
- linux - 如何计算linux机器中的内存利用率百分比?
- css - 我需要文本以特定宽度出现在 2 行中,然后文本从第二行以省略号形式溢出——使用纯 css?
- android - 当我在 MotionLayout 中使用 RecyclerView 和 SwipeRefreshLayout 做一些动画时,事情变得很奇怪
- function - 我想要函数返回这个列表