-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 3.1.0+ breaks SASS modules composition #7682
Comments
Created a related issue in the |
It seems this is a css-loader issue per webpack-contrib/css-loader#131. They have closed that issue but I suspect that it is not fixed. I suggest anyone who arrives here may need to agitate on that issue to get this fixed. |
I'm using react-app-rewired to temporarily fix this issue. const findSassModuleRule = (config) => {
let sassModuleRuleIndex;
const cssLoaderModule = config.module.rules.find(ruleItem => {
if (!ruleItem.oneOf || !ruleItem.oneOf.length) {
return false;
}
sassModuleRuleIndex = ruleItem.oneOf.findIndex(
loaderItem =>
loaderItem.test &&
loaderItem.test.toString() === "/\\.module\\.(scss|sass)$/"
);
return sassModuleRuleIndex !== -1;
});
const sassModuleRule = cssLoaderModule.oneOf[sassModuleRuleIndex];
return sassModuleRule;
};
// Remove resolve-url-loader which causes SASS modules to not work properly
// TODO: Remove this when below issue gets fixed
// https://github.com/facebook/create-react-app/issues/7682
const removeResolveUrlLoader = (config) => {
const sassModuleRule = findSassModuleRule(config);
sassModuleRule.use = sassModuleRule.use.filter(
loaderItem =>
!(loaderItem.loader && loaderItem.loader.includes("/resolve-url-loader/"))
);
return config;
};
module.exports = function override(config) {
config = removeResolveUrlLoader(config);
return config;
} Hope this helps before this issue gets fixed. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue. |
Is there any workaround? I am having the same issue. See #8144 for more detail |
Hi, Same issue here, in 3.0.1 everything is going well. But as soon as I bump version to 3.1.0, I get the same error as @igor10k. (3.2.0 doesn't work either) @crux153 workaround is working well for developement, but the build fails to compile with error :
Hope it helps. Thanks for you work on react. |
This issue remains with react-scripts 3.3.0. Curiously: almost the same configuration (v3.3.0 as well) is working fine in another project which also makes use of SASS modules and I can't figure out the difference. |
@Ralmo the issue happens only when you |
@igor10k Well I'll be... I completely missunderstood the reason for this error and assumed it was due to react-scripts > 3.1.0 + usage of SASS modules in general. I thought the error was related to the Your guess was completely on point, thank you! |
Is there any progress on this? I use 'composes' in my projects heavily and got stuck with older versions of CRA because of this issue. |
I miss the times when the CRA team cared more about the stability of the package. Now they've added |
It seems react-scripts 3.3.1 with PR #8281 fixes this issue. Now my project builds fine without removing the resolve-url-loader. |
Just tried to upgrade from 3.0.1 to 3.3.1 and still got that issue... So for me it does not solve the problem |
Still broken on 3.3.1 |
Does somebody have had the same issue with url images. I have. a message like ' Module not found: Can't resolve in '. |
I created a fresh project with 3.3.1 with the exact structure as OP described and everything now compiles just fine. But it's hard to believe that the fix was that simple. |
It works good for me now with version 3.3.1 |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Bump? |
I still have this issue with 3.4.1, I switched to 3.4.0 and 3.3.0, removed package-lock and node_modules, reinstalled everything and it still doesn't work. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue. |
had this problem too! |
@phongyewtong but do you have it now, what version of CRA do you use? Could you share a repo reproducing the problem if so? |
Describe the bug
In 3.1.0 the
resolve-url-loader
lib was added that breaks SASS modules composition. Either removing the lib from the webpack config or downgrading to 3.0.1 fixes the issue.Did you try recovering your dependencies?
Yes. Deleted
node-modules
and removed thepackage-lock.json
.Environment
Steps to reproduce
npx create-react-app test_app && cd test_app
yarn add node-sass
b.module.sass
witha.module.sass
withApp.js
add as the first lineimport './a.module.sass'
yarn start
and observe the errorb.module.sass
tob.module.css
and replace the contents witha.module.sass
changeb.module.sass
tob.module.css
Expected behavior
Build succeeds.
Actual behavior
Build fails.
Reproducible demo
https://github.com/Igor10k/rca_sass_modules_bug
The text was updated successfully, but these errors were encountered: