Skip to content

Commit e59678a

Browse files
committed
Improve sass-loader modern API configuration
Update configuration to properly handle full path loaders and maintain existing sassOptions while adding the modern API flag
1 parent bcac070 commit e59678a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

config/webpack/commonWebpackConfig.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,23 @@ const scssConfigIndex = baseClientWebpackConfig.module.rules.findIndex((config)
2929

3030
// Configure sass-loader to use the modern API
3131
const scssRule = baseClientWebpackConfig.module.rules[scssConfigIndex];
32-
const sassLoaderIndex = scssRule.use.findIndex((loader) =>
33-
loader.loader === 'sass-loader' || (typeof loader === 'string' && loader.includes('sass-loader'))
34-
);
32+
const sassLoaderIndex = scssRule.use.findIndex((loader) => {
33+
if (typeof loader === 'string') {
34+
return loader.includes('sass-loader');
35+
}
36+
return loader.loader && loader.loader.includes('sass-loader');
37+
});
3538

3639
if (sassLoaderIndex !== -1) {
3740
const sassLoader = scssRule.use[sassLoaderIndex];
3841
if (typeof sassLoader === 'string') {
3942
scssRule.use[sassLoaderIndex] = {
40-
loader: 'sass-loader',
43+
loader: sassLoader,
4144
options: {
42-
api: 'modern'
45+
api: 'modern',
46+
sassOptions: {
47+
includePaths: []
48+
}
4349
}
4450
};
4551
} else {

0 commit comments

Comments
 (0)