我是 stackoverflow 的新手,想问你一个我在互联网上找不到的问题......我希望我在好网站上 :)
所以这是我的问题:我想将一些 css 文件从 node_modules 依赖项导入到反应应用程序中。我使用 webpack 进行开发,但出现了一个我不明白的错误,这在标题中。所以这是编译器的错误详细信息:
ERROR in ./src/scss/app.scss
Module not found: Error: Can't find options with ident 'postcss'
@ ./src/scss/app.scss 9:10-188
@ ./src/app/App.js
@ ./src/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./src
另外,在导航控制台中我得到了这个:
Error: Cannot find module '-!../../node_modules/css-loader/index.js?{"importLoaders":1}!../../node_modules/postcss-loader/lib/index.js??postcss!react-big-calendar/lib/css/react-big-calendar.css'
那是我的 scss 文件的内容无法加载 css 文件。应用程序.scss:
exports.i(require("-!../../node_modules/css-loader/index.js?{\"importLoaders\":1}!../../node_modules/postcss-loader/lib/index.js??postcss!react-big-calendar/lib/css/react-big-calendar.css"), "");
你也可以查看我的 webpack 配置文件:
const HtmlWebPackPlugin = require("html-webpack-plugin");
const htmlWebpackPlugin = new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html"
});
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
]
}
]
},
plugins: [htmlWebpackPlugin],
resolve: {
extensions: ['.js', '.jsx', '.json', '.css']
}
};
我的代码有什么问题?
非常感谢你帮助我!如果我不是很清楚,请询问我任何其他信息