尝试手动编译和捆绑反应应用程序
当我在 JS 文件中导入我的 scss 文件时弹出此错误
ERROR in ./containers/DashboardApp/DashboardApp.scss
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
TypeError: Cannot read property 'nodes' of undefined
at getCustomPropertiesFromRoot (/Users/ashishnegi/Desktop/work/Digitour/node_modules/postcss-custom-properties/index.cjs:48:8)
at Object.prepare (/Users/ashishnegi/Desktop/work/Digitour/node_modules/postcss-custom-properties/index.cjs:491:28)
at LazyResult.plugins.processor.plugins.map.plugin (/Users/ashishnegi/Desktop/work/Digitour/node_modules/postcss/lib/lazy-result.js:149:39)
at Array.map (<anonymous>)
at new LazyResult (/Users/ashishnegi/Desktop/work/Digitour/node_modules/postcss/lib/lazy-result.js:147:43)
at Processor.process (/Users/ashishnegi/Desktop/work/Digitour/node_modules/postcss/lib/processor.js:28:14)
at Object.loader (/Users/ashishnegi/Desktop/work/Digitour/node_modules/postcss-loader/dist/index.js:97:30)
@ ./containers/DashboardApp/DashboardApp.js 37:0-44 41:15-37
@ ./routes/MainRoutes.js 3:0-67 7:15-27
@ ./index.js 19:0-45 20:104-114
webpack 5.65.0 compiled with 1 error in 3258 ms
这里有什么问题?如果我不导入 scss 文件,它会很好。我基本上需要让我的项目一起编译,导入所有必要的文件
附加配置文件
module.exports = {
entry: "./index.js",
output: {
filename: "main.js",
path: path.resolve("dist"),
publicPath: "/"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: "babel-loader"
},
{
test: /\.html$/,
use: "html-loader"
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
"postcss-preset-env"
]
}
}
},
"style-loader",
"css-loader",
"sass-loader"
]
}
]
},
plugins: [
new HTMLWebpackPlugin({
template: "index.tpl.html",
filename: "index.html"
})
]
}