Skip to content

Commit e302a48

Browse files
author
Valentin Hervieu
committed
Support absolute imports for SASS
1 parent 2af9789 commit e302a48

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

packages/react-scripts/config/custom-react-scripts/customizers/webpack-loaders.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ module.exports = {
99
get: styleLoader(undefined, /\.css$/, /\.module\.css$/),
1010
},
1111
SASS: {
12-
get: styleLoader(sassLoader, /\.s[ac]ss$/, /\.module\.s[ac]ss$/),
12+
get: styleLoader(
13+
sassLoader,
14+
/\.s[ac]ss$/,
15+
/\.module\.s[ac]ss$/,
16+
false,
17+
{ includePaths: ['./node_modules', './src'] }
18+
),
1319
},
1420
LESS: {
1521
get: styleLoader(lessLoader, /\.less$/, /\.module\.less$/),
@@ -24,7 +30,12 @@ module.exports = {
2430
get: styleLoader(lessLoader, /\.module\.less$/, undefined, true),
2531
},
2632
SASS_MODULES: {
27-
get: styleLoader(sassLoader, /\.module\.s[ac]ss$/, undefined, true),
33+
get: styleLoader(
34+
sassLoader,
35+
/\.module\.s[ac]ss$/,
36+
undefined,
37+
true,
38+
{ includePaths: ['./node_modules', './src'], }),
2839
},
2940
CSS_MODULES: {
3041
get: styleLoader(undefined, /\.module\.css$/, undefined, true),

packages/react-scripts/config/custom-react-scripts/webpack-config/style-loader.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const localIdentName =
66
process.env.REACT_APP_CSS_MODULE_CLASSNAME_TEMPLATE ||
77
'[sha512:hash:base32]-[name]-[local]';
88

9-
module.exports = (loader, test, exclude, modules) => isDev => {
9+
module.exports = (loader, test, exclude, modules, options) => isDev => {
1010
let loaders = isDev
1111
? [
1212
{
@@ -42,9 +42,11 @@ module.exports = (loader, test, exclude, modules) => isDev => {
4242
if (loader) {
4343
loaders.push({
4444
loader,
45-
options: {
46-
sourceMap: shouldUseSourceMap,
47-
},
45+
options: Object.assign(
46+
{},
47+
{ sourceMap: shouldUseSourceMap },
48+
options
49+
),
4850
});
4951
}
5052

0 commit comments

Comments
 (0)