-
-
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
create-react-app sass sourcemaps not working #5707
Comments
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. |
Any estimate for an official fix on this? Thanks. |
Any Updates on this ? |
I suspect the team isn't moving particularly fast on this (btw team you are doing an excellent job!), because the react approach favours component level styling over a sass approach. However if sass is being support then source maps probably should be too. I'd certainly find it useful! |
Anybody have temporarily solution ? :( |
@agairing Those changes would be lost on every |
@NotAmaan Right. It's just intended as a temporary solution (if you need working source maps - like myself....). |
bump. |
I tried the solution from @agairing - but the source maps all point to main.scss and not the individual scss files. So there is still something missing. [edit] process.env.GENERATE_SOURCEMAP needed to be set to true. |
Thanks @agairing for the workaround suggestion. Could anyone share some light on whether an official fix is being considered? Would be much appreciated (even if later than sooner, but at least to know if it will be officially fixed eventually) Also, I've created the following SO post a while back, just in case anyone wanna jump in: Thank you. |
@ianschmitz |
@ianschmitz Thanks so much for the reply! Tried updating to 2.1.3 yesterday but still wasn't working, would be up on next release? |
Please follow #5713 for updates. |
Will do, thanks again. |
This is fixed in the latest release. |
This will be reverted because of #6399. |
Any news on this? |
Are there any updates on this? This seems to still be an issue on Chrome even with CRA 3.0.0 |
Seems the PR above (#7114) is closed now, just posted to see if we can bring attention back to it. After 8 months, an official word on this would be appreciated, if there is no interest in providing a fix in the short term, please make us aware. Thank you. |
Thanks for being patient and sorry for the slowness. Personally I'm not keen on providing a solution that would cause issues when turned on even when it's behind a flag. People would just raise more issues against these problems. If you really need this feature you can use a third party solution like react-app-rewired. |
Jack thanks so much for the reply! Just to clarify from your post, a fix without breaking other stuff would not be feasible? Thanks again. |
We've attempted to release this change before, it isn't that it doesn't work (it does), but turns out it causes other significant problems like FOUC and perf degrading. If we release the same change behind a flag, these issues will inevitably be raised again. |
@bugzpodder Could you point to an upstream bug thats causing this? We could keep an eye on that to look for when it could be merged in. Source map support is one of those basic things that any web application development framework, plugin or tool should support. If it is not supported, it should be clearly mentioned in the README somewhere so people are sure what they're investing their personal/company resources in and how painful it would be to work with, don't you think? |
Once other problems like #6399 no longer manifests we will revisit this issue. Currently I am not aware of any upstream PRs that would fix any of these problems. |
@bugzpodder |
@mostafaabobakr7 See #5707 (comment) |
Any estimate for an official fix on this? Thanks. (CRA 3.0.1) |
I have been waiting for this to be resolved for more than half a year... Before it was resolved, we will always have to use the workaround here, but still, it is just a workaround, so it would still be better if there is an official solution as soon as possible. This issue depends on #5707 (comment), which seems to be... promising in their 3.1 milestone (not sure about it)? |
Hi all! I think I know what is going on and how to fix it. BackgroundThe ability to enable source maps during development was originally added in #5713 and released in v2.1.4. Unfortunately, enabling source maps during development caused a flash of unstyled content (FOUC), which was reported in #6399. To resolve that issue, support for source maps during development was removed in #6399 and released in v2.1.6. CauseThe FOUC occured because JS rendered before CSS. JS rendered before CSS because style-loader injected Faulty WorkaroundSo, why ever inject This is why the SolutionThe solution, I hope, is to share this history with the style-loader team and submit a PR to restore the original fix. And here it is! webpack-contrib/style-loader#383 |
@jonathantneal that's awesome! Appreciate your effort here and hopefully we can find a resolution for this soon! |
A couple updates
|
I have an updated version of @zaderac's craco snippet. Enables
|
So to officially move this forward does someone need to make a pull request that re-applies the changes from #5713? |
@zhuoli99 Would you consider resending your PR to fix this issue? Can be quite a pain for quite a lot of people. |
Would it violate any etiquette/rules (spoken or unspoken) if someone besides @zhuoli99 made a pull request that re-applies the changes from #5713? |
@PsiRadish No, you're fine, just validate that the issue that caused it to be reverted is actually fixed! I'll commit to reviewing :) |
Alternatively, you may use this script to manipulate the webpack config - doesn't require CRACO or its huge config.
const { writeFileSync, existsSync, readFileSync } = require('fs');
const path = 'node_modules/react-scripts/config/webpack.config.js';
const find = /(sourceMap: isEnvProduction && shouldUseSourceMap)/g;
const replace = 'sourceMap: isEnvDevelopment && shouldUseSourceMap';
if (existsSync(path)) {
const buffer = readFileSync(path)
.toString()
.replace(find, replace);
try {
writeFileSync(path, buffer);
console.info('enable-css-sourcemaps: active');
} catch (e) {
console.error(`enable-css-sourcemaps: ${path} manipulation failed!`);
}
} else {
console.warn(`enable-css-sourcemaps: ${path} does not exist`);
}
|
I think i found the issue in react-script\config\webpack-config.js sourcemaps never get enabled in developement environement. |
Hey, seems like there hasn't been any action on this thread in a while. I just submitted a PR with (I think) the changes discussed above #8638 |
This fixed it for me for the moment. How can i avoid this problem in future projects? |
Sass sourcemaps shows only on
yarn build
Can we have sourcemaps enabled by default in development !
yarn start
Environment
Node: v11.1.0
yarn: v1.12.1
npm: v6.4.1
Chrome: v70
The text was updated successfully, but these errors were encountered: