样式加载器,带有css模块的键入,加载器使用webpack

样式加载器,带有css模块的键入,加载器使用webpack,webpack,sass,webpack-style-loader,Webpack,Sass,Webpack Style Loader,我想使用样式加载器使用webpack将SCS加载到我的TypeScript组件。当仅使用css时,我有以下一组规则: { test: /\.css$/, loader: "style-loader" }, { test: /\.css$/, loader: "typings-for-css-modules-loader?modules&namedExport" } 它的工作原理与预期一致 但是,当我尝试使用sass(遵循软件包页面上的指南)时,它会变成: { test: /\.css$

我想使用样式加载器使用webpack将SCS加载到我的TypeScript组件。当仅使用css时,我有以下一组规则:

{ test: /\.css$/, loader: "style-loader" },
{ test: /\.css$/, loader: "typings-for-css-modules-loader?modules&namedExport" }
它的工作原理与预期一致

但是,当我尝试使用sass(遵循软件包页面上的指南)时,它会变成:

{ test: /\.css$/, loader: "style-loader" },
{ test: /\.css$/, loader: "typings-for-css-modules-loader?modules&namedExport" },
{ test: /\.scss$/, loader: "typings-for-css-modules-loader?modules&namedExport&sass" },
这不起作用,因为我在结果中没有看到任何样式标记


我是否遗漏了一些东西,或者没有真正理解它是如何工作的

我发现以下两个修改允许加载sass模块。第一个是更改
样式加载器
测试,使其也包括scss文件。第二个是添加
sass加载程序
作为scss文件的初始加载程序。您可能需要安装sass加载程序包。因此,现在的规则是:

{ test: /\.(css|scss)$/, loader: "style-loader" },
{ test: /\.css$/, loader: "typings-for-css-modules-loader?modules&namedExport" },
{ test: /\.scss$/, loader: "typings-for-css-modules-loader?modules&namedExport&sass" },
{ test: /\.scss$/, loader: "sass-loader" }