Reactjs 在react中导入SCS:找不到模块SCS

Reactjs 在react中导入SCS:找不到模块SCS,reactjs,webpack,sass,Reactjs,Webpack,Sass,我正在尝试导入scs并在react css themr中使用它,所以当我不使用themr时,这个导入工作正常:import style/Sample.scss,但现在我需要将它存储在一个对象中并在themr中使用它,所以我尝试将其命名为:import*as SampleTheme from style/Sample.scss&这会导致找不到模块的错误,我在终端本身中遇到了这个错误,所以构建过程无法进行。我还尝试了const SampleTheme=requirestyle/Sample.scss

我正在尝试导入scs并在react css themr中使用它,所以当我不使用themr时,这个导入工作正常:import style/Sample.scss,但现在我需要将它存储在一个对象中并在themr中使用它,所以我尝试将其命名为:import*as SampleTheme from style/Sample.scss&这会导致找不到模块的错误,我在终端本身中遇到了这个错误,所以构建过程无法进行。我还尝试了const SampleTheme=requirestyle/Sample.scss,但这给了我一个空白对象

有些人说webpack配置有问题,但我对此不太确定,因为在IDE中,当我在上面停留时,我可以看到同样的问题&直到webpack还没有运行,这里仍然是我的SCS webpack配置:

{
    test: /\.scss$/,
    use: [
        {
            loader: 'style-loader'
        }, {
            loader: 'css-loader',
            options: {
                importLoaders: 1,
                sourceMap: false,
            }
        }, {
            loader: 'sass-loader',
            options: {
                includePaths: [
                    path.join(__dirname, 'src'),
                    path.join(__dirname, 'src', 'styles'),
                    path.join(__dirname, 'src', 'styles', 'components'),
                ],
                sourceMap: false
            }
        }, {
            loader: 'sass-resources-loader',
            options: {
                resources: [
                    './node_modules/engage-ui/src/styles/foundation.scss',
                    './node_modules/engage-ui/themes/Delicious/foundation.scss',
                    './node_modules/engage-ui/src/styles/shared.scss',
                    './node_modules/engage-ui/themes/Delicious/shared.scss',
                ],
            },
        },
    ],
    exclude: /node_modules/
},
并添加sass加载程序

纱线添加sass加载程序节点sass–开发


我已经在我的配置文件中添加了所有这3个加载程序,请检查上面的代码
module.exports = {
...
  module: {
    rules: [{
        test: /\.scss$/,
        use: [{
            loader: "style-loader" // creates style nodes from JS strings
        }, {
            loader: "css-loader" // translates CSS into CommonJS
        }, {
            loader: "sass-loader" // compiles Sass to CSS
        }]
    }]
  }
};