Skip to content

Commit bcac070

Browse files
committed
Fix Sass legacy JS API deprecation warnings
Configure sass-loader to use the modern API to avoid deprecation warnings about the legacy JS API being removed in Dart Sass 2.0.0
1 parent 51f6272 commit bcac070

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

config/webpack/commonWebpackConfig.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ const scssConfigIndex = baseClientWebpackConfig.module.rules.findIndex((config)
2727
'.scss'.match(config.test),
2828
);
2929

30+
// Configure sass-loader to use the modern API
31+
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+
);
35+
36+
if (sassLoaderIndex !== -1) {
37+
const sassLoader = scssRule.use[sassLoaderIndex];
38+
if (typeof sassLoader === 'string') {
39+
scssRule.use[sassLoaderIndex] = {
40+
loader: 'sass-loader',
41+
options: {
42+
api: 'modern'
43+
}
44+
};
45+
} else {
46+
sassLoader.options = sassLoader.options || {};
47+
sassLoader.options.api = 'modern';
48+
}
49+
}
50+
3051
baseClientWebpackConfig.module.rules[scssConfigIndex].use.push(sassLoaderConfig);
3152

3253
// Copy the object using merge b/c the baseClientWebpackConfig and commonOptions are mutable globals

0 commit comments

Comments
 (0)