Webpack无法在node_modules中找到scss
{
test: /\.scss$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{
loader: 'sass-loader',
options: {
includePaths: ['./node_modules'],
sourceMap: true
}
}
]
},
并在SCSS文件中。.
@import '~bootstrap-sass/assets/stylesheets/bootstrap';
@import '~bootstrap-sass/assets/stylesheets/bootstrap';
^
File to import not found or unreadable: ~bootstrap-sass/assets/stylesheets/bootstrap.
答案 0 :(得分:0)
您应该和我一起检查您的配置,我认为您不需要使用includePaths: ['./node_modules'],
{
test: /\.scss$/,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
minimize: true,
sourceMap: true
}
},
{
loader: "sass-loader"
}
]
},
然后我可以毫无问题地导入它
@import "~bootstrap/scss/bootstrap";
@import "~font-awesome/scss/font-awesome";
@import "~toastr/toastr";
@import "~react-select/dist/react-select.css";
@import "~react-bootstrap-table/dist/react-bootstrap-table-all.min.css";
您可以找到我的完整配置here